Clear        


                
                    @using APP.Domain

@model UserRequest

@* Generated from Custom MVC Template. *@
@* Model namespace using directive should be added to _ViewImports.cshtml. *@

@{
    var containerDivClass = "container"; // "container-fluid" can be used for full width
    var dateTimePickerClass = "datetimepicker"; // "jquery-datetimepicker" must be added as client side library
}
@{
    /*
    ViewBag and ViewData are the same collection (dictionary).
    They carry extra data other than the model from a controller action to its view, or between views.
    The value assigned will be shown in Views\Shared\_Layout.cshtml view's title tag of the head tag.
    */
    ViewData["Title"] = "User Edit";
}

<div class="@containerDivClass">
    <h1>@ViewData["Title"]</h1>
    <hr />
</div>

@if (Model is not null)
{
<div class="@containerDivClass">
    @if (TempData["Message"] is not null)
    {
    /*
    TempData is used to carry extra data to the redirected controller action's view.
    */
    <p class="text-danger">
        @TempData["Message"]
    </p>
    }
    <form asp-action="Edit" autocomplete="off" enctype="multipart/form-data">
	    @Html.AntiForgeryToken()
        <div asp-validation-summary="All" class="text-danger"></div> @* Use ModelOnly instead of All to see only service response messages in validation summary *@
        <div class="row mb-3">
            <label asp-for="UserName" class="col-2 col-form-label fw-bold"></label>
	        <div class="col-10">
	            <input asp-for="UserName" class="form-control" />
		        <span asp-validation-for="UserName" class="text-danger"></span>
	        </div>
        </div>
        <div class="row mb-3">
            <label asp-for="Password" class="col-2 col-form-label fw-bold"></label>
	        <div class="col-10">
	            <input asp-for="Password" class="form-control" />
		        <span asp-validation-for="Password" class="text-danger"></span>
	        </div>
        </div>
        <div class="row mb-3">
            <label asp-for="FirstName" class="col-2 col-form-label fw-bold"></label>
	        <div class="col-10">
	            <input asp-for="FirstName" class="form-control" />
		        <span asp-validation-for="FirstName" class="text-danger"></span>
	        </div>
        </div>
        <div class="row mb-3">
            <label asp-for="LastName" class="col-2 col-form-label fw-bold"></label>
	        <div class="col-10">
	            <input asp-for="LastName" class="form-control" />
		        <span asp-validation-for="LastName" class="text-danger"></span>
	        </div>
        </div>
        <div class="row mb-3">
            <label asp-for="Gender" class="col-2 col-form-label fw-bold"></label>
            <div class="col-10">
                <select asp-for="Gender" class="form-select">
                    <option value="@((int)Genders.Woman)">
                        @Genders.Woman
                    </option>
                    <option value="@((int)Genders.Man)">
                        @Genders.Man
                    </option>
                    @* 
                Updated by APP.Domain.Genders enum elements. 
                APP.Domain namespace added on top. 
                *@
                </select>
                <span asp-validation-for="Gender" class="text-danger"></span>
            </div>
        </div>
        <div class="row mb-3">
            <label asp-for="BirthDate" class="col-2 col-form-label fw-bold"></label>
	        <div class="col-10">
		        <input asp-for="BirthDate" class="form-control @dateTimePickerClass" type="text" />
		        <span asp-validation-for="BirthDate" class="text-danger"></span>
	        </div>
        </div>
        @* 
            RegistrationDate request property removed since 
            it is assigned automatically in the UserService 
            Add method.
        *@
        @if (User.IsInRole("Admin"))
        {
            <div class="row mb-3">
                <label asp-for="Score" 
                    class="col-2 col-form-label fw-bold"></label>
	        <div class="col-10">
	            <input asp-for="Score" class="form-control" />
		        <span asp-validation-for="Score" class="text-danger"></span>
	        </div>
        </div>
        }
        @* 
            IsOnline request property removed since 
            it will be assigned automatically in the  
            log in and log out operations.
        *@
        @if (User.IsInRole("Admin"))
        {
        <div class="row mb-3">
            <label asp-for="StatusId" 
                class="col-2 col-form-label fw-bold"></label>
            <div class="col-10">
	            <select asp-for="StatusId" class="form-select" 
                    asp-items="ViewBag.StatusId">
		            <option value="">-- Select --</option>
	            </select>
	            <span asp-validation-for="StatusId" class="text-danger"></span>
            </div>
        </div>
        }
        <input type="hidden" asp-for="Id" />

@* Can be uncommented and used for many to many relationships, "entity" may be replaced with the related entity name in the controller and views. *@
        @if (User.IsInRole("Admin"))
        {
        <div class="row mb-3">
            <label asp-for="RoleIds" 
                class="col-2 col-form-label fw-bold"></label>
	        <div class="col-10">
		        <select multiple asp-for="RoleIds" class="form-select" 
                    asp-items="ViewBag.RoleIds"></select>
		        <span asp-validation-for="RoleIds" class="text-danger"></span>
	        </div>
        </div>
        }

        <hr />
        <div class="row mb-3">
	        <div class="offset-2 col-10">
                <button type="submit" class="btn btn-primary">Save</button>
		        &nbsp;&nbsp;
                <button type="reset" class="btn btn-outline-primary">Reset</button>
		        &nbsp;&nbsp;
                <a asp-action="Delete" asp-route-id="@Model.Id">Delete</a>
                &nbsp;&nbsp;
		        <a asp-action="Index">Back to List</a>
	        </div>
        </div>
    </form>
</div>
}

@section Scripts {
    @* Can be uncommented to use client-side validation using jQuery instead of server-side validation. *@
    @*<partial name="_ValidationScriptsPartial" />*@
    
    @* https://xdsoft.net/jqplugins/datetimepicker *@
    <link href="~/lib/jquery-datetimepicker/jquery.datetimepicker.min.css" rel="stylesheet" />
    <script src="~/lib/jquery-datetimepicker/jquery.datetimepicker.full.min.js"></script>
    <script>
        $(function () {
            $(".datetimepicker").datetimepicker({
                // for using only date
                timepicker: false,
                format: 'm/d/Y'
                // for using date with time
                // timepicker: true,
                // format: 'm/d/Y H:i'
            });
        });
    </script>
}