File size: 2,876 Bytes
fc06b79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@model ContactManagementAPI.ViewModels.UserEditViewModel
@{
    ViewData["Title"] = "Edit User";
    var groups = ViewData["Groups"] as IEnumerable<ContactManagementAPI.Models.UserGroup>;
}

<div class="form-container">
    <h2><i class="fas fa-user-edit"></i> Edit User</h2>

    <form method="post" asp-action="EditUser">
        @Html.AntiForgeryToken()
        <input type="hidden" asp-for="Id" />

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

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

        <div class="form-group">
            <label>Group <span style="color:red;">*</span></label>
            <select asp-for="GroupId" class="form-control">
                <option value="">-- Select Group --</option>
                @if (groups != null)
                {
                    foreach (var group in groups)
                    {
                        if (Model.GroupId == group.Id)
                        {
                            <option value="@group.Id" selected="selected">@group.Name</option>
                        }
                        else
                        {
                            <option value="@group.Id">@group.Name</option>
                        }
                    }
                }
            </select>
        </div>

        <div class="form-group">
            <label asp-for="NewPassword">Reset Password</label>
            <input asp-for="NewPassword" class="form-control" type="password" placeholder="Leave blank to keep current password" />
            <span asp-validation-for="NewPassword" class="text-danger"></span>
        </div>

        <div class="form-row" style="display:flex; gap:20px;">
            <div class="form-check">
                <input asp-for="IsAdmin" class="form-check-input" type="checkbox" />
                <label asp-for="IsAdmin" class="form-check-label">Admin</label>
            </div>
            <div class="form-check">
                <input asp-for="IsActive" class="form-check-input" type="checkbox" />
                <label asp-for="IsActive" class="form-check-label">Active</label>
            </div>
        </div>

        <div class="form-actions">
            <button type="submit" class="btn btn-primary">Save</button>
            <a href="/admin/users" class="btn btn-secondary">Cancel</a>
            <a href="/admin/userrights/@Model.Id" class="btn btn-info">Manage Rights</a>
        </div>
    </form>
</div>

@section Scripts {
    <partial name="_ValidationScriptsPartial" />
}