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

Commit 422c5cc

Browse files
committed
Client
1 parent 2f66588 commit 422c5cc

59 files changed

Lines changed: 22212 additions & 70 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public DomainToViewModelMappingProfile()
1818
CreateMap<StoredEvent, EventHistoryData>().ConstructUsing(a => new EventHistoryData() { Action = a.MessageType, Id = a.Id.ToString(), Details = a.Data, When = a.Timestamp.ToString(CultureInfo.InvariantCulture), Who = a.User });
1919
CreateMap<Client, ClientListViewModel>(MemberList.Destination);
2020
CreateMap<IdentityServer4.EntityFramework.Entities.Secret, SecretViewModel>(MemberList.Destination);
21+
CreateMap<IdentityServer4.EntityFramework.Entities.ClientProperty, ClientPropertyViewModel>();
22+
CreateMap<IdentityServer4.EntityFramework.Entities.ClientClaim, ClientClaimViewModel>();
2123
}
2224
}
2325
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ public ViewModelToDomainMappingProfile()
3838
*/
3939
CreateMap<Client, UpdateClientCommand>().ConstructUsing(c => new UpdateClientCommand(c));
4040
CreateMap<RemoveSecretViewModel, RemoveSecretCommand>().ConstructUsing(c => new RemoveSecretCommand(c.Id, c.ClientId));
41+
CreateMap<RemovePropertyViewModel, RemovePropertyCommand>().ConstructUsing(c => new RemovePropertyCommand(c.Id, c.ClientId));
4142
CreateMap<SaveClientSecretViewModel, SaveClientSecretCommand>().ConstructUsing(c => new SaveClientSecretCommand(c.ClientId, c.Description, c.Value, c.Type, c.Expiration, (int)c.Hash.GetValueOrDefault(HashType.Sha256)));
43+
CreateMap<SaveClientPropertyViewModel, SaveClientPropertyCommand>().ConstructUsing(c => new SaveClientPropertyCommand(c.ClientId, c.Key, c.Value));
44+
45+
CreateMap<SaveClientClaimViewModel, SaveClientClaimCommand>().ConstructUsing(c => new SaveClientClaimCommand(c.ClientId, c.Type, c.Value));
46+
CreateMap<RemoveClientClaimViewModel, RemoveClientClaimCommand>().ConstructUsing(c => new RemoveClientClaimCommand(c.Id, c.ClientId));
4247
}
4348
}
4449
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,11 @@ public interface IClientAppService: IDisposable
1414
Task<IEnumerable<SecretViewModel>> GetSecrets(string clientId);
1515
Task RemoveSecret(RemoveSecretViewModel model);
1616
Task SaveSecret(SaveClientSecretViewModel model);
17+
Task<IEnumerable<ClientPropertyViewModel>> GetProperties(string clientId);
18+
Task RemoveProperty(RemovePropertyViewModel model);
19+
Task SaveProperty(SaveClientPropertyViewModel model);
20+
Task<IEnumerable<ClientClaimViewModel>> GetClaims(string clientId);
21+
Task RemoveClaim(RemoveClientClaimViewModel model);
22+
Task SaveClaim(SaveClientClaimViewModel model);
1723
}
1824
}

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

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,26 @@ public class ClientAppService : IClientAppService
1818
private IMapper _mapper;
1919
private IEventStoreRepository _eventStoreRepository;
2020
private readonly IClientRepository _clientRepository;
21+
private readonly IClientPropertyRepository _clientPropertyRepository;
22+
private readonly IClientSecretRepository _clientSecretRepository;
23+
private readonly IClientClaimRepository _clientClaimRepository;
2124
public IMediatorHandler Bus { get; set; }
2225

2326
public ClientAppService(IMapper mapper,
2427
IMediatorHandler bus,
2528
IEventStoreRepository eventStoreRepository,
26-
IClientRepository clientRepository)
29+
IClientRepository clientRepository,
30+
IClientPropertyRepository clientPropertyRepository,
31+
IClientSecretRepository clientSecretRepository,
32+
IClientClaimRepository clientClaimRepository)
2733
{
2834
_mapper = mapper;
2935
Bus = bus;
3036
_eventStoreRepository = eventStoreRepository;
3137
_clientRepository = clientRepository;
38+
_clientPropertyRepository = clientPropertyRepository;
39+
_clientSecretRepository = clientSecretRepository;
40+
_clientClaimRepository = clientClaimRepository;
3241
}
3342

3443
public Task<IEnumerable<ClientListViewModel>> GetClients()
@@ -51,7 +60,7 @@ public Task Update(Client client)
5160

5261
public async Task<IEnumerable<SecretViewModel>> GetSecrets(string clientId)
5362
{
54-
return _mapper.Map<IEnumerable<SecretViewModel>>(await _clientRepository.GetSecrets(clientId));
63+
return _mapper.Map<IEnumerable<SecretViewModel>>(await _clientSecretRepository.GetByClientId(clientId));
5564
}
5665

5766
public Task RemoveSecret(RemoveSecretViewModel model)
@@ -66,6 +75,40 @@ public Task SaveSecret(SaveClientSecretViewModel model)
6675
return Bus.SendCommand(registerCommand);
6776
}
6877

78+
public async Task<IEnumerable<ClientPropertyViewModel>> GetProperties(string clientId)
79+
{
80+
return _mapper.Map<IEnumerable<ClientPropertyViewModel>>(await _clientPropertyRepository.GetByClientId(clientId));
81+
}
82+
83+
public Task RemoveProperty(RemovePropertyViewModel model)
84+
{
85+
var registerCommand = _mapper.Map<RemovePropertyCommand>(model);
86+
return Bus.SendCommand(registerCommand);
87+
}
88+
public Task SaveProperty(SaveClientPropertyViewModel model)
89+
{
90+
var registerCommand = _mapper.Map<SaveClientPropertyCommand>(model);
91+
return Bus.SendCommand(registerCommand);
92+
}
93+
94+
public async Task<IEnumerable<ClientClaimViewModel>> GetClaims(string clientId)
95+
{
96+
return _mapper.Map<IEnumerable<ClientClaimViewModel>>(await _clientClaimRepository.GetByClientId(clientId));
97+
}
98+
99+
public Task RemoveClaim(RemoveClientClaimViewModel model)
100+
{
101+
102+
var registerCommand = _mapper.Map<RemoveClientClaimCommand>(model);
103+
return Bus.SendCommand(registerCommand);
104+
}
105+
106+
public Task SaveClaim(SaveClientClaimViewModel model)
107+
{
108+
var registerCommand = _mapper.Map<SaveClientClaimCommand>(model);
109+
return Bus.SendCommand(registerCommand);
110+
}
111+
69112
public void Dispose()
70113
{
71114
GC.SuppressFinalize(this);

src/Backend/Jp.Application/ViewModels/ClientsViewModels/ClientClaimViewModel.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ namespace Jp.Application.ViewModels.ClientsViewModels
88
public class ClientClaimViewModel
99
{
1010
public ClientClaimViewModel() { }
11-
public ClientClaimViewModel(string type, string value)
12-
{
13-
Type = type;
14-
Value = value;
15-
}
1611

1712
public int Id { get; set; }
1813
public string Type { get; set; }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Jp.Application.ViewModels.ClientsViewModels
2+
{
3+
public class ClientPropertyViewModel
4+
{
5+
public int Id { get; set; }
6+
public string Key { get; set; }
7+
public string Value { get; set; }
8+
}
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace Jp.Application.ViewModels.ClientsViewModels
4+
{
5+
public class RemoveClientClaimViewModel
6+
{
7+
[Required]
8+
public int Id { get; set; }
9+
[Required]
10+
public string ClientId { get; set; }
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace Jp.Application.ViewModels.ClientsViewModels
4+
{
5+
public class RemovePropertyViewModel
6+
{
7+
[Required]
8+
public int Id { get; set; }
9+
[Required]
10+
public string ClientId { get; set; }
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace Jp.Application.ViewModels.ClientsViewModels
4+
{
5+
public class SaveClientClaimViewModel
6+
{
7+
[Required]
8+
public string Value { get; set; }
9+
[Required]
10+
public string Type { get; set; }
11+
[Required]
12+
public string ClientId { get; set; }
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace Jp.Application.ViewModels.ClientsViewModels
4+
{
5+
public class SaveClientPropertyViewModel
6+
{
7+
[Required]
8+
public string Value { get; set; }
9+
[Required]
10+
public string Key { get; set; }
11+
[Required]
12+
public string ClientId { get; set; }
13+
}
14+
}

0 commit comments

Comments
 (0)