Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 42d7259

Browse files
committed
roles complete
1 parent 44f6ed8 commit 42d7259

55 files changed

Lines changed: 12706 additions & 149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Backend/Jp.Application/AutoMapper/DomainToViewModelMappingProfile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Jp.Domain.Models;
1111
using System.Globalization;
1212
using System.Security.Claims;
13+
using Jp.Application.ViewModels.RoleViewModels;
1314

1415
namespace Jp.Application.AutoMapper
1516
{

src/Backend/Jp.Application/AutoMapper/ViewModelToDomainMappingProfile.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public ViewModelToDomainMappingProfile()
8888
* Role commands
8989
*/
9090
CreateMap<RemoveRoleViewModel, RemoveRoleCommand>().ConstructUsing(c => new RemoveRoleCommand(c.Name));
91+
CreateMap<SaveRoleViewModel, SaveRoleCommand>().ConstructUsing(c => new SaveRoleCommand(c.Name));
92+
CreateMap<UpdateRoleViewModel, UpdateRoleCommand>().ConstructUsing(c => new UpdateRoleCommand(c.Name, c.OldName));
93+
CreateMap<RemoveUserFromRoleViewModel, RemoveUserFromRoleCommand>().ConstructUsing(c => new RemoveUserFromRoleCommand(c.Role, c.Username));
9194

9295
}
9396
}

src/Backend/Jp.Application/Interfaces/IRoleManagerAppService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ public interface IRoleManagerAppService: IDisposable
1111
{
1212
Task<IEnumerable<RoleViewModel>> GetAllRoles();
1313
Task Remove(RemoveRoleViewModel model);
14+
Task<RoleViewModel> GetDetails(string name);
15+
Task Save(SaveRoleViewModel model);
16+
Task Update(UpdateRoleViewModel model);
17+
Task RemoveUserFromRole(RemoveUserFromRoleViewModel model);
1418
}
1519
}

src/Backend/Jp.Application/Interfaces/IUserManageAppService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading.Tasks;
44
using Jp.Application.EventSourcedNormalizers;
55
using Jp.Application.ViewModels;
6+
using Jp.Application.ViewModels.RoleViewModels;
67
using Jp.Application.ViewModels.UserViewModels;
78
using Jp.Domain.Models;
89

@@ -30,5 +31,6 @@ public interface IUserManageAppService : IDisposable
3031
Task SaveRole(SaveUserRoleViewModel model);
3132
Task<IEnumerable<UserLoginViewModel>> GetLogins(string userName);
3233
Task RemoveLogin(RemoveUserLoginViewModel model);
34+
Task<IEnumerable<UserListViewModel>> GetUsersInRole(string[] role);
3335
}
3436
}

src/Backend/Jp.Application/Services/RoleManagerAppService.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,28 @@ public Task Remove(RemoveRoleViewModel model)
4545
var command = _mapper.Map<RemoveRoleCommand>(model);
4646
return Bus.SendCommand(command);
4747
}
48+
49+
public async Task<RoleViewModel> GetDetails(string name)
50+
{
51+
return _mapper.Map<RoleViewModel>(await _roleService.Details(name));
52+
}
53+
54+
public Task Save(SaveRoleViewModel model)
55+
{
56+
var command = _mapper.Map<SaveRoleCommand>(model);
57+
return Bus.SendCommand(command);
58+
}
59+
60+
public Task Update(UpdateRoleViewModel model)
61+
{
62+
var command = _mapper.Map<UpdateRoleCommand>(model);
63+
return Bus.SendCommand(command);
64+
}
65+
66+
public Task RemoveUserFromRole(RemoveUserFromRoleViewModel model)
67+
{
68+
var command = _mapper.Map<RemoveUserFromRoleCommand>(model);
69+
return Bus.SendCommand(command);
70+
}
4871
}
4972
}

src/Backend/Jp.Application/Services/UserManagerAppService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Collections.Generic;
1212
using System.Linq;
1313
using System.Threading.Tasks;
14+
using Jp.Application.ViewModels.RoleViewModels;
1415

1516
namespace Jp.Application.Services
1617
{
@@ -154,6 +155,10 @@ public Task RemoveLogin(RemoveUserLoginViewModel model)
154155
return Bus.SendCommand(registerCommand);
155156
}
156157

158+
public async Task<IEnumerable<UserListViewModel>> GetUsersInRole(string[] role)
159+
{
160+
return _mapper.Map<IEnumerable<UserListViewModel>>(await _userService.GetUserFromRole(role));
161+
}
157162
}
158163
}
159164

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Jp.Application.ViewModels.RoleViewModels
2+
{
3+
public class RemoveUserFromRoleViewModel
4+
{
5+
public string Role { get; set; }
6+
public string Username { get; set; }
7+
}
8+
}

src/Backend/Jp.Application/ViewModels/RoleViewModels/RoleViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Jp.Application.ViewModels
3+
namespace Jp.Application.ViewModels.RoleViewModels
44
{
55
public class RoleViewModel
66
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Jp.Application.ViewModels.RoleViewModels
2+
{
3+
public class SaveRoleViewModel
4+
{
5+
public string Name { get; set; }
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Jp.Application.ViewModels.RoleViewModels
2+
{
3+
public class UpdateRoleViewModel
4+
{
5+
public string Name { get; set; }
6+
public string OldName { get; set; }
7+
}
8+
}

0 commit comments

Comments
 (0)