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

Commit 63bae3a

Browse files
committed
client details
1 parent 2a8e47b commit 63bae3a

85 files changed

Lines changed: 49201 additions & 550 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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using IdentityServer4.Models;
44
using Jp.Application.EventSourcedNormalizers;
55
using Jp.Application.ViewModels;
6+
using Jp.Application.ViewModels.ClientsViewModels;
67
using Jp.Domain.Core.Events;
78
using Jp.Domain.Models;
89

@@ -12,9 +13,10 @@ public class DomainToViewModelMappingProfile : Profile
1213
{
1314
public DomainToViewModelMappingProfile()
1415
{
16+
CreateMap<Client, ClientViewModel>();
1517
CreateMap<User, UserViewModel>().ForMember(a => a.Password, o => o.Ignore()).ForMember(a => a.ConfirmPassword, o => o.Ignore());
1618
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});
17-
19+
CreateMap<Client, ClientListViewModel>(MemberList.Destination);
1820
}
1921
}
2022
}

src/Backend/Jp.Application/EventSourcedNormalizers/CustomerHistory.cs

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Threading.Tasks;
5+
using IdentityServer4.Models;
6+
using Jp.Application.ViewModels;
7+
8+
namespace Jp.Application.Interfaces
9+
{
10+
public interface IApiResourceAppService: IDisposable
11+
{
12+
Task<IEnumerable<ApiResource>> GetApiResources();
13+
}
14+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Text;
43
using System.Threading.Tasks;
54
using IdentityServer4.Models;
6-
using Jp.Application.ViewModels;
5+
using Jp.Application.ViewModels.ClientsViewModels;
76

87
namespace Jp.Application.Interfaces
98
{
109
public interface IClientAppService: IDisposable
1110
{
12-
Task<IEnumerable<Client>> GetClients();
11+
Task<IEnumerable<ClientListViewModel>> GetClients();
12+
Task<Client> GetClientDetails(string clientId);
1313
}
1414
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using AutoMapper;
6+
using IdentityServer4.EntityFramework.Mappers;
7+
using IdentityServer4.Models;
8+
using Jp.Application.Interfaces;
9+
using Jp.Application.ViewModels;
10+
using Jp.Domain.Core.Bus;
11+
using Jp.Domain.Interfaces;
12+
13+
namespace Jp.Application.Services
14+
{
15+
public class ApiResourceAppService : IApiResourceAppService
16+
{
17+
private IMapper _mapper;
18+
private IEventStoreRepository _eventStoreRepository;
19+
private readonly IApiResourceRepository _apiResourceRepository;
20+
public IMediatorHandler Bus { get; set; }
21+
22+
public ApiResourceAppService(IMapper mapper,
23+
IMediatorHandler bus,
24+
IEventStoreRepository eventStoreRepository,
25+
IApiResourceRepository apiResourceRepository)
26+
{
27+
_mapper = mapper;
28+
Bus = bus;
29+
_eventStoreRepository = eventStoreRepository;
30+
_apiResourceRepository = apiResourceRepository;
31+
}
32+
33+
34+
public Task<IEnumerable<ApiResource>> GetApiResources()
35+
{
36+
var resultado = _apiResourceRepository.GetAll().Select(a => a.ToModel()).ToList();
37+
return Task.FromResult<IEnumerable<ApiResource>>(resultado);
38+
}
39+
public void Dispose()
40+
{
41+
GC.SuppressFinalize(this);
42+
}
43+
}
44+
}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using IdentityServer4.EntityFramework.Mappers;
77
using IdentityServer4.Models;
88
using Jp.Application.Interfaces;
9+
using Jp.Application.ViewModels.ClientsViewModels;
910
using Jp.Domain.Core.Bus;
1011
using Jp.Domain.Interfaces;
1112

@@ -15,7 +16,7 @@ public class ClientAppService : IClientAppService
1516
{
1617
private IMapper _mapper;
1718
private IEventStoreRepository _eventStoreRepository;
18-
private readonly IClientRepository _ClientRepository;
19+
private readonly IClientRepository _clientRepository;
1920
public IMediatorHandler Bus { get; set; }
2021

2122
public ClientAppService(IMapper mapper,
@@ -26,15 +27,21 @@ public ClientAppService(IMapper mapper,
2627
_mapper = mapper;
2728
Bus = bus;
2829
_eventStoreRepository = eventStoreRepository;
29-
_ClientRepository = clientRepository;
30+
_clientRepository = clientRepository;
3031
}
3132

32-
public Task<IEnumerable<Client>> GetClients()
33+
public Task<IEnumerable<ClientListViewModel>> GetClients()
3334
{
35+
var resultado = _mapper.Map<IEnumerable<ClientListViewModel>>(_clientRepository.GetAll().Select(a => a.ToModel()).OrderBy(a => a.ClientName).ToList());
36+
return Task.FromResult(resultado);
37+
}
3438

35-
var resultado = _ClientRepository.GetAll().Select(a => a.ToModel()).ToList();
36-
return Task.FromResult<IEnumerable<Client>>(resultado);
39+
public async Task<Client> GetClientDetails(string clientId)
40+
{
41+
var resultado = await _clientRepository.GetByUniqueName(clientId);
42+
return resultado.ToModel();
3743
}
44+
3845
public void Dispose()
3946
{
4047
GC.SuppressFinalize(this);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.ComponentModel.DataAnnotations;
3+
4+
namespace Jp.Application.ViewModels
5+
{
6+
public class ClientViewModel
7+
{
8+
9+
10+
11+
}
12+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Jp.Application.ViewModels.ClientsViewModels
6+
{
7+
public class ClientListViewModel
8+
{
9+
/// <summary>
10+
/// Unique ID of the client
11+
/// </summary>
12+
public string ClientId { get; set; }
13+
/// <summary>
14+
/// Client display name (used for logging and consent screen)
15+
/// </summary>
16+
public string ClientName { get; set; }
17+
/// <summary>
18+
/// Specifies if client is enabled (defaults to <c>true</c>)
19+
/// </summary>
20+
public bool Enabled { get; set; }
21+
/// <summary>
22+
/// URI to client logo (used on consent screen)
23+
/// </summary>
24+
public string LogoUri { get; set; }
25+
}
26+
}

src/Backend/Jp.Application/ViewModels/ConfirmEmailViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.ComponentModel.DataAnnotations;
2+
using Jp.Domain.Core.Models;
23

34
namespace Jp.Application.ViewModels
45
{
@@ -9,5 +10,6 @@ public class ConfirmEmailViewModel
910
public string Email { get; set; }
1011
[Required]
1112
public string Code { get; set; }
13+
1214
}
1315
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using Jp.Domain.Commands.ApiResource;
4+
using Jp.Domain.Core.Bus;
5+
using Jp.Domain.Core.Notifications;
6+
using Jp.Domain.Interfaces;
7+
using MediatR;
8+
9+
namespace Jp.Domain.CommandHandlers
10+
{
11+
public class ApiResourceCommandHandler : CommandHandler,
12+
IRequestHandler<RegisterApiResourceCommand>
13+
{
14+
private readonly IApiResourceRepository _apiResourceRepository;
15+
16+
public ApiResourceCommandHandler(
17+
IUnitOfWork uow,
18+
IMediatorHandler bus,
19+
INotificationHandler<DomainNotification> notifications,
20+
IApiResourceRepository apiResourceService) : base(uow, bus, notifications)
21+
{
22+
_apiResourceRepository = apiResourceService;
23+
}
24+
25+
26+
public Task Handle(RegisterApiResourceCommand request, CancellationToken cancellationToken)
27+
{
28+
if (!request.IsValid())
29+
{
30+
NotifyValidationErrors(request);
31+
return Task.CompletedTask;
32+
}
33+
34+
// Businness logic here
35+
36+
//if (Commit())
37+
//{
38+
// Bus.RaiseEvent(new ApiResourceRegisteredEvent(ApiResource.Id));
39+
//}
40+
41+
return Task.CompletedTask;
42+
}
43+
44+
}
45+
}

0 commit comments

Comments
 (0)