mirror of https://github.com/abpframework/abp
				
				
				
			
							parent
							
								
									02dec7af51
								
							
						
					
					
						commit
						0bed7db506
					
				| @ -1,62 +0,0 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Volo.Abp.AspNetCore.Mvc; | ||||
| using Volo.Abp.Identity.Web.Areas.Identity.Models; | ||||
| 
 | ||||
| namespace Volo.Abp.Identity.Web.Areas.Identity.Controllers | ||||
| { | ||||
|     //[Area("Identity")] | ||||
|     //[Authorize] | ||||
|     //public class UsersController : AbpController | ||||
|     //{ | ||||
|     //    private readonly IIdentityUserAppService _identityUserAppService; | ||||
|     //    private readonly IIdentityRoleAppService _identityRoleAppService; | ||||
| 
 | ||||
|     //    public UsersController(IIdentityUserAppService identityUserAppService, IIdentityRoleAppService identityRoleAppService) | ||||
|     //    { | ||||
|     //        _identityUserAppService = identityUserAppService; | ||||
|     //        _identityRoleAppService = identityRoleAppService; | ||||
|     //    } | ||||
| 
 | ||||
|     //    public async Task<PartialViewResult> Update(Guid id) | ||||
|     //    { | ||||
|     //        var user = await _identityUserAppService.GetAsync(id); | ||||
|     //        await _identityRoleAppService.GetAllListAsync(); | ||||
|     //        var model = await CreateViewModel(user); | ||||
| 
 | ||||
|     //        return PartialView("_Update", model); | ||||
|     //    } | ||||
| 
 | ||||
|     //    private async Task<CreateOrUpdateUserViewModel> CreateViewModel(IdentityUserDto user) | ||||
|     //    { | ||||
|     //        var allRoles = await _identityRoleAppService.GetAllListAsync(); | ||||
| 
 | ||||
|     //        var model = new CreateOrUpdateUserViewModel | ||||
|     //        { | ||||
|     //            User = user ?? new IdentityUserDto(), | ||||
|     //            Roles = ObjectMapper.Map<List<IdentityRoleDto>, IdentityUserRoleDto[]>(allRoles) | ||||
|     //        }; | ||||
| 
 | ||||
|     //        var userRoles = new List<IdentityRoleDto>(); | ||||
| 
 | ||||
|     //        if (user != null) | ||||
|     //        { | ||||
|     //            userRoles = (await _identityUserAppService.GetRolesAsync(user.Id)).Items.ToList(); | ||||
|     //        } | ||||
| 
 | ||||
|     //        foreach (var role in model.Roles) | ||||
|     //        { | ||||
|     //            if (userRoles.Select(x=>x.Name).Contains(role.Name)) | ||||
|     //            { | ||||
|     //                role.IsAssigned = true; | ||||
|     //            } | ||||
|     //        } | ||||
| 
 | ||||
|     //        return model; | ||||
|     //    } | ||||
|     //} | ||||
| } | ||||
| @ -1,66 +0,0 @@ | ||||
| @using Microsoft.Extensions.Localization | ||||
| @using Volo.Abp.Identity.Web.Areas.Identity.Localization.Resource | ||||
| @model Volo.Abp.Identity.Web.Areas.Identity.Models.CreateOrUpdateUserViewModel | ||||
| @inject IStringLocalizer<IdentityResource> Localizer | ||||
| <div class="modal-header"> | ||||
|     <h5 class="modal-title" id="userModalLabel">@Localizer["CreateUser"]</h5> | ||||
|     <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||||
|         <span aria-hidden="true">×</span> | ||||
|     </button> | ||||
| </div> | ||||
| <div class="modal-body"> | ||||
|     <form id="createUserForm"> | ||||
|         <!-- Nav tabs --> | ||||
|         <ul class="nav nav-tabs" role="tablist"> | ||||
|             <li class="nav-item"> | ||||
|                 <a class="nav-link active" data-toggle="tab" href="#userInformations" role="tab">@Localizer["CreateUser"]</a> | ||||
|             </li> | ||||
|             <li class="nav-item"> | ||||
|                 <a class="nav-link" data-toggle="tab" href="#roles" role="tab">@Localizer["Roles"]</a> | ||||
|             </li> | ||||
|         </ul> | ||||
| 
 | ||||
|         <!-- Tab panes --> | ||||
|         <div class="tab-content pt-3"> | ||||
| 
 | ||||
|             <div class="tab-pane active" id="userInformations" role="tabpanel"> | ||||
| 
 | ||||
|                 <div class="form-group"> | ||||
|                     <label for="userName">@Localizer["UserName"]</label> | ||||
|                     <input type="text" class="form-control" id="userName" name="UserName" placeholder="User name"> | ||||
|                 </div> | ||||
|                 <div class="form-group"> | ||||
|                     <label for="password">@Localizer["Password"]</label> | ||||
|                     <input type="password" class="form-control" id="password" name="Password" placeholder="Password"> | ||||
|                 </div> | ||||
|                 <div class="form-group"> | ||||
|                     <label for="email">@Localizer["EmailAddress"]</label> | ||||
|                     <input type="email" class="form-control" id="email" name="Email" placeholder="Enter email"> | ||||
|                 </div> | ||||
|                 <div class="form-group"> | ||||
|                     <label for="phoneNumber">@Localizer["PhoneNumber"]</label> | ||||
|                     <input type="tel" class="form-control" id="phoneNumber" name="PhoneNumber" placeholder="Phone number"> | ||||
|                 </div> | ||||
| 
 | ||||
|             </div> | ||||
|             <div class="tab-pane" id="roles" role="tabpanel"> | ||||
|                 <div class="user-role-checkbox-list"> | ||||
|                     @foreach (var role in Model.Roles) | ||||
|                     { | ||||
|                         <div class="form-check"> | ||||
|                             <label class="form-check-label"> | ||||
|                                 <input id="CreateUser_@(role.Name)" class="form-check-input" type="checkbox" name="@(role.Name)" value="true" @Html.Raw(role.IsAssigned ? "checked=\"checked\"" : "")> | ||||
|                                 @role.Name | ||||
|                             </label> | ||||
|                         </div> | ||||
|                     } | ||||
|                 </div> | ||||
|             </div> | ||||
| 
 | ||||
|         </div> | ||||
|     </form> | ||||
| </div> | ||||
| <div class="modal-footer"> | ||||
|     <button type="button" class="btn btn-secondary" data-dismiss="modal">@Localizer["Close"]</button> | ||||
|     <button type="button" class="btn btn-primary" id="btnCreateUserSave">@Localizer["Save"]</button> | ||||
| </div> | ||||
| @ -0,0 +1,42 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Threading.Tasks; | ||||
| using Volo.Abp.AspNetCore.Mvc.RazorPages; | ||||
| 
 | ||||
| namespace Volo.Abp.Identity.Web.Pages.Identity.Users | ||||
| { | ||||
|     public class EditModalModel : AbpPageModel | ||||
|     { | ||||
|         public IdentityUserDto EditingUser { get; set; } | ||||
|         public IdentityUserRoleDto[] Roles { get; set; } | ||||
| 
 | ||||
|         private readonly IIdentityUserAppService _identityUserAppService; | ||||
|         private readonly IIdentityRoleAppService _identityRoleAppService; | ||||
| 
 | ||||
|         public EditModalModel(IIdentityUserAppService identityUserAppService, IIdentityRoleAppService identityRoleAppService) | ||||
|         { | ||||
|             _identityUserAppService = identityUserAppService; | ||||
|             _identityRoleAppService = identityRoleAppService; | ||||
|         } | ||||
| 
 | ||||
|         public async Task OnGetAsync(Guid id) | ||||
|         { | ||||
|             EditingUser = await _identityUserAppService.GetAsync(id); | ||||
|             Roles = ObjectMapper.Map<List<IdentityRoleDto>, IdentityUserRoleDto[]>(await _identityRoleAppService.GetAllListAsync()); | ||||
|             await SetAssignedRoles(); | ||||
|         } | ||||
| 
 | ||||
|         private async Task SetAssignedRoles() | ||||
|         { | ||||
|             var userRoleNames = (await _identityUserAppService.GetRolesAsync(EditingUser.Id)).Items.Select(r => r.Name).ToList(); | ||||
|             foreach (var role in Roles) | ||||
|             { | ||||
|                 if (userRoleNames.Contains(role.Name)) | ||||
|                 { | ||||
|                     role.IsAssigned = true; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue
	
	 Halil İbrahim Kalkan
						Halil İbrahim Kalkan