profileShare

rasmusjy / splitapp-backend-clean-onion

Read-only snapshot

No repository description.

main default branch 429 files Expires Sep 13, 2026, 9:06 AM
BudgetCategoryBllDtoFactory.cs 1,115 bytes
1 using App.BLL.DTO;
2 using App.Domain;
3
4 namespace App.BLL.Mappers;
5
6 public static class BudgetCategoryBllDtoFactory
7 {
8 public static BudgetCategoryBllDto Create(BudgetCategory 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 Name = entity.Name,
16 IconName = entity.IconName,
17 PlannedAmount = entity.PlannedAmount,
18 DisplayOrder = entity.DisplayOrder,
19 ExpenseCount = entity.Expenses?.Count ?? 0,
20 SpentAmount = entity.Expenses?.Sum(e => e.Amount) ?? 0
21 };
22
23 public static List<BudgetCategoryBllDto> CreateList(IEnumerable<BudgetCategory> entities)
24 => entities.Select(Create).ToList();
25
26 public static BudgetCategory ToEntity(BudgetCategoryBllDto dto) => new()
27 {
28 Id = dto.Id,
29 TripId = dto.TripId,
30 Name = dto.Name,
31 IconName = dto.IconName,
32 PlannedAmount = dto.PlannedAmount,
33 DisplayOrder = dto.DisplayOrder
34 };
35 }
36