@model RegisterViewModel

@{
    ViewData["Title"] = "Register";
}


<div class="container mt-4">
    <div class="card justify-content-center">
        <div class="card-body">
            <h5 class="card-title">Create banner</h5>

            <div class="row ">
                <!-- 12 columns for textboxes -->

                <form asp-action="Register">
                    <div asp-validation-summary="ModelOnly" class="text-danger"></div>

                    <div class="form-group">
                        <label asp-for="FirstName"></label>
                        <input asp-for="FirstName" class="form-control" />
                        <span asp-validation-for="FirstName" class="text-danger"></span>
                    </div>
                    <div class="form-group">
                        <label asp-for="LastName"></label>
                        <input asp-for="LastName" class="form-control" />
                        <span asp-validation-for="LastName" class="text-danger"></span>
                    </div>
                    <div class="form-group">
                        <label asp-for="Email"></label>
                        <input asp-for="Email" class="form-control" />
                        <span asp-validation-for="Email" class="text-danger"></span>
                    </div>

                    <div class="form-group">
                        <label asp-for="Password"></label>
                        <input asp-for="Password" class="form-control" type="password" />
                        <span asp-validation-for="Password" class="text-danger"></span>
                    </div>

                    <div class="form-group">
                        <label asp-for="ConfirmPassword"></label>
                        <input asp-for="ConfirmPassword" class="form-control" type="password" />
                        <span asp-validation-for="ConfirmPassword" class="text-danger"></span>
                    </div>

                    <div class="form-group">
                        <label asp-for="SelectedRoles">Roles</label>
                        <div>
                            @foreach (var role in Model.Roles)
                            {
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="@role.Value" name="SelectedRoles" value="@role.Value">
                                    <label class="form-check-label" for="@role.Value">
                                        @role.Text
                                    </label>
                                </div>
                            }
                        </div>
                        <button type="button" class="btn btn-secondary btn-sm" onclick="selectAllRoles(this)">Select All</button>
                        <span asp-validation-for="SelectedRoles" class="text-danger"></span>
                    </div>

                    <div class="mb-3">
                        <input type="submit" value="Register" class="btn btn-outline-primary" /> |    <a asp-action="Index" class="btn btn-primary">Back to list</a>
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>


@section Scripts {

   
    @{
        <partial name="_ValidationScriptsPartial" />
    }
    <script>
        function selectAllRoles(button) {
            var isChecked = button.textContent.includes("Select");
            var checkboxes = document.getElementsByName('SelectedRoles');
            for (var checkbox of checkboxes) {
                checkbox.checked = isChecked;
            }
            button.textContent = isChecked ? "Deselect All" : "Select All"; // Toggle button text
        }
    </script>
}





