-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from GerardGargan/dev
marge dev to master
- Loading branch information
Showing
5 changed files
with
185 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Bookstore.Models.ViewModels | ||
{ | ||
public class UserRoleVM | ||
{ | ||
public ApplicationUser User { get; set; } | ||
public IEnumerable<SelectListItem> RoleList { get; set; } | ||
public IEnumerable<SelectListItem> CompanyList { get; set; } | ||
Check warning on line 14 in Bookstore.Models/ViewModels/UserRoleVM.cs
|
||
public string RoleId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Bookstore.Web/Areas/Admin/Views/User/RoleManagement.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@model UserRoleVM | ||
|
||
@{ | ||
var isCompanyUser = Model.User.CompanyId == null ? "display: none" : ""; | ||
} | ||
|
||
<div class="card shadow border-0 my-4"> | ||
<div class="card-header bg-secondary bg-gradient ml-0 py-3"> | ||
<div class="row"> | ||
<div class="col-12 text-center"> | ||
<h2 class="text-white py-2">Manage User</h2> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="card-body p-4"> | ||
<form method="POST" class="row" enctype="multipart/form-data"> | ||
<input asp-for="@Model.User.Id" hidden /> | ||
<div class="border p-3"> | ||
<div class="form-floating py-2 col-12"> | ||
<input asp-for="User.Name" class="form-control border-0 shadow" /> | ||
<label asp-for="User.Name" class="ms-2"></label> | ||
<span asp-validation-for="User.Name" class="text-danger p-0"></span> | ||
</div> | ||
<div class="form-floating py-2 col-12"> | ||
<select asp-for="RoleId" asp-items="@Model.RoleList" class="form-select border-0 shadow"> | ||
<option disabled selected>--Select Role--</option> | ||
</select> | ||
<label asp-for="@Model.User.Role" class="ms-2"></label> | ||
</div> | ||
<div class="form-floating py-2 col-12"> | ||
<select asp-for="User.CompanyId" asp-items="@Model.CompanyList" class="form-select border-0 shadow" style="@isCompanyUser"> | ||
<option disabled selected>--Select Company--</option> | ||
</select> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
@section Scripts { | ||
<partial name="_ValidationScriptsPartial" /> | ||
<script> | ||
$(document).ready(function () { | ||
$('#RoleId').change(function () { | ||
console.log("Change event"); | ||
let roleSelected = $('#RoleId Option:Selected').text(); | ||
if (roleSelected == 'Company') { | ||
console.log("Show"); | ||
$('#User_CompanyId').show(); | ||
} else { | ||
console.log("Hide"); | ||
$('#User_CompanyId').hide(); | ||
} | ||
}); | ||
}); | ||
</script> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters