InvitationBllDtoFactory.cs
1,211 bytes
| 1 | using SplitApp.Modules.Trips.Domain.Entities; |
|---|---|
| 2 | using SplitApp.WebApp.Application.DTO; |
| 3 | |
| 4 | namespace SplitApp.WebApp.Application.Mappers; |
| 5 | |
| 6 | public static class InvitationBllDtoFactory |
| 7 | { |
| 8 | public static TripInvitationBllDto Create(TripInvitation entity) => new() |
| 9 | { |
| 10 | Id = entity.Id, |
| 11 | CreatedAt = entity.CreatedAt, |
| 12 | UpdatedAt = entity.UpdatedAt, |
| 13 | TripId = entity.TripId, |
| 14 | Trip = entity.Trip != null ? TripBllDtoFactory.Create(entity.Trip) : null, |
| 15 | InvitedByUserId = entity.InvitedByUserId, |
| 16 | InvitedByUser = AppUserBllDtoFactory.Create(entity.InvitedByUser), |
| 17 | Token = entity.Token, |
| 18 | Status = entity.Status, |
| 19 | ExpiresAt = entity.ExpiresAt, |
| 20 | RespondedAt = entity.RespondedAt |
| 21 | }; |
| 22 | |
| 23 | public static List<TripInvitationBllDto> CreateList(IEnumerable<TripInvitation> entities) |
| 24 | => entities.Select(Create).ToList(); |
| 25 | |
| 26 | public static TripInvitation ToEntity(TripInvitationBllDto dto) => new() |
| 27 | { |
| 28 | Id = dto.Id, |
| 29 | TripId = dto.TripId, |
| 30 | InvitedByUserId = dto.InvitedByUserId, |
| 31 | Token = dto.Token, |
| 32 | Status = dto.Status, |
| 33 | ExpiresAt = dto.ExpiresAt, |
| 34 | RespondedAt = dto.RespondedAt |
| 35 | }; |
| 36 | } |
| 37 | |