
@{
    ViewData["Title"] = "Edit User Account";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

@model EForT.Models.AdminModel

<div class="app-content container center-layout py-3">
    <div class="content-header row">
        <div class="content-header-left col-12 mb-2">
            <h1 class="content-header-title mb-0">Edit User</h1>
            <div class="row breadcrumbs-top">
                <div class="breadcrumb-wrapper col-12">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="@Url.Action("AdminAccount", "UserManagement")">Administrator Home</a>
                        </li>
                        <li class="breadcrumb-item">
                            <a href="@Url.Action("ViewUsersAccount", "UserManagement")">User Management </a>
                        </li>
                        <li class="breadcrumb-item active">
                            Edit User
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <div class="content-wrapper">
        <div class="content-body">
            <div class="row">
                <div class="col-12 col-sm-12 col-md-8 col-lg-6 col-xl-6">
                    <div class="card">
                        <div class="card-header pb-0">
                            <div class="font-medium-2 bottom-border">
                                <p>Account Details</p>
                            </div>
                        </div>
                        <div class="card-content">
                            <div class="card-body">
                                <form id="editUserForm" asp-action="EditUserAccount" asp-controller="UserManagement" method="post">
                                    <input type="hidden" asp-for="OriginalUsername" id="OriginalUsername" />
                                    <input type="hidden" asp-for="OriginalEmail" id="OriginalEmail" />
                                    <input type="hidden" asp-for="EditUser.LoginId" id="LoginId" />
                                    <fieldset class="form-group">
                                        <label for="Username">Username <i class="warning">*</i></label>
                                        <input type="text" class="form-control" asp-for="Username" id="Username" placeholder="Username must be 8-15 characters" maxlength="15" required>
                                        <span asp-validation-for="Username" class="error-text"></span>
                                    </fieldset>
                                    <fieldset class="form-group">
                                        <label for="UserEmail">Email Address <i class="warning">*</i></label>
                                        <input type="email" class="form-control" asp-for="Email" id="Email" maxlength="100" required>
                                        <p class="mb-0 text-muted">User will be contacted primarily through email. Please provide a valid email address.</p>
                                        <span asp-validation-for="Email" class="error-text"></span>
                                    </fieldset>
                                    <fieldset class="form-group">
                                        <label for="RoleID">Role <i class="warning">*</i></label>
                                        <select class="form-control" asp-for="EditUser.RoleId" id="RoleID" required>
                                            <option value="" selected disabled>Select</option>
                                            @if (Model.ListRoles != null)
                                            {
                                                if (Model.ListRoles.Count > 0)
                                                {
                                                    for (int i = 0; i < Model.ListRoles.Count; i++)
                                                    {
                                                        <option value="@Model.ListRoles[i].Id">@Model.ListRoles[i].Description</option>
                                                    }
                                                }
                                            }
                                        </select>
                                    </fieldset>
                                    <fieldset class="form-group">
                                        <label for="UserFirstName">First Name <i class="warning">*</i></label>
                                        <input type="text" asp-for="EditUser.FirstName" class="form-control" id="UserFirstName" required>
                                    </fieldset>
                                    <fieldset class="form-group">
                                        <label for="UserLastName">Last Name <i class="warning">*</i></label>
                                        <input type="text" asp-for="EditUser.LastName" class="form-control" id="UserLastName" required>
                                    </fieldset>
                                    <fieldset class="form-group">
                                        <label for="pickerUserDOB">Date of Birth</label>
                                        <input type="text" class="form-control" asp-for="EditUser.DateOfBirth" id="pickerUserDOB" required>
                                    </fieldset>
                                    <fieldset class="form-group">
                                        <label for="UserPhone">Phone Number <i class="warning">*</i></label>
                                        <input type="text" asp-for="EditUser.Phone" class="form-control" id="UserPhone" required>
                                    </fieldset>
                                    <fieldset class="form-group">
                                        <label for="LoginEnabled">Enable/Disable Account:</label>
                                        <label id="LoginEnabled" class="switch">
                                            <input type="checkbox" asp-for="EditUser.Enabled" id="LoginEnabled">
                                            <span class="slider round"></span>
                                        </label>
                                    </fieldset>
                                    <div class="row pt-2">
                                        <div class="px-1 pb-1">
                                            <button type="submit" class="btn btn-primary">Save Changes</button>
                                        </div>
                                        <div class="pb-1">
                                            <a href="@Url.Action("ViewUsersAccount", "UserManagement")" class="btn btn-secondary">Back</a>
                                        </div>
                                    </div>
                                </form>                                
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>