diff options
author | HombreLaser <sebastian-440@live.com> | 2022-11-22 18:01:02 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2022-11-22 18:01:02 -0600 |
commit | 17b13d82dd0cd4ceba513d3354ade9420528e7bf (patch) | |
tree | 71b88eb5a0fb15790364484ee2cac6f801291db9 /Profiles | |
parent | 214cd4db690635ba2a30183c1679c3e4d7b8e896 (diff) |
Añadido método show en el controlador de usuarios
Diffstat (limited to 'Profiles')
-rw-r--r-- | Profiles/UserAccountProfile.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Profiles/UserAccountProfile.cs b/Profiles/UserAccountProfile.cs index 073b86b..7695265 100644 --- a/Profiles/UserAccountProfile.cs +++ b/Profiles/UserAccountProfile.cs @@ -6,6 +6,25 @@ namespace BackendPIA.Profiles { public class UserAccountProfile : Profile { public UserAccountProfile() { CreateMap<UserAccountForm, UserAccount>().ReverseMap(); + CreateMap<UserAccount, UserAccountDTO>().ForMember(dto => dto.Tickets, o => o.MapFrom(UserTickets)); + } + + private ICollection<TicketDTO> UserTickets(UserAccount user, UserAccountDTO dto) { + ICollection<TicketDTO> tickets = new List<TicketDTO>(); + + if(user.Tickets == null) + return tickets; + + foreach (var ticket in user.Tickets) { + tickets.Add(new TicketDTO { + Id = ticket.Id, + Number = ticket.Number, + IsWinner = ticket.IsWinner, + RaffleId = ticket.RaffleId + }); + } + + return tickets; } } } |