diff options
Diffstat (limited to 'Profiles/UserAccountProfile.cs')
-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; } } } |