profileShare

rasmusjy / splitapp-backend-clean-onion

Read-only snapshot

No repository description.

main default branch 429 files Expires Sep 13, 2026, 9:06 AM
WishlistBllDtoFactory.cs 1,999 bytes
1 using App.BLL.DTO;
2 using App.Domain;
3
4 namespace App.BLL.Mappers;
5
6 public static class WishlistBllDtoFactory
7 {
8 public static TripWishlistItemBllDto Create(TripWishlistItem 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 AddedByUserId = entity.AddedByUserId,
16 AddedByUser = entity.AddedByUser != null ? new AppUserBllDto
17 {
18 Id = entity.AddedByUser.Id,
19 FirstName = entity.AddedByUser.FirstName,
20 LastName = entity.AddedByUser.LastName,
21 Email = entity.AddedByUser.Email
22 } : null,
23 Title = entity.Title,
24 Description = entity.Description,
25 Category = entity.Category,
26 Priority = entity.Priority,
27 EstimatedCost = entity.EstimatedCost,
28 Url = entity.Url,
29 Location = entity.Location,
30 IsCompleted = entity.IsCompleted,
31 CompletedAt = entity.CompletedAt,
32 DisplayOrder = entity.DisplayOrder,
33 VoteCount = entity.Votes?.Count(v => v.IsInterested) ?? 0,
34 VoterUserIds = entity.Votes?.Where(v => v.IsInterested).Select(v => v.UserId).ToList() ?? new List<Guid>()
35 };
36
37 public static List<TripWishlistItemBllDto> CreateList(IEnumerable<TripWishlistItem> entities)
38 => entities.Select(Create).ToList();
39
40 public static TripWishlistItem ToEntity(TripWishlistItemBllDto dto) => new()
41 {
42 Id = dto.Id,
43 TripId = dto.TripId,
44 AddedByUserId = dto.AddedByUserId,
45 Title = dto.Title,
46 Description = dto.Description,
47 Category = dto.Category,
48 Priority = dto.Priority,
49 EstimatedCost = dto.EstimatedCost,
50 Url = dto.Url,
51 Location = dto.Location,
52 IsCompleted = dto.IsCompleted,
53 CompletedAt = dto.CompletedAt,
54 DisplayOrder = dto.DisplayOrder
55 };
56 }
57