From 6d734bbf798f0950197343df9e97708edd378779 Mon Sep 17 00:00:00 2001 From: mfnefd Date: Wed, 27 Nov 2024 00:26:18 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B=20=D1=80?= =?UTF-8?q?=D0=B0=D1=81=D1=85=D0=BE=D0=B4=D0=BE=D0=B2=20=D1=82=D0=B0=D0=BA?= =?UTF-8?q?=D0=B6=D0=B5=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=8F=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B5=D0=B9=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B1=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/Contracts/DTOs/SpendingGroupDto.cs | 1 + back/Infrastructure/Models/Changerecord.cs | 2 +- back/Infrastructure/Models/SpendingGroup.cs | 1 + back/Infrastructure/Models/User.cs | 1 + back/Infrastructure/Repositories/SpendingGroupRepo.cs | 3 ++- back/Infrastructure/Support/Mappers/SpendingGroupMapper.cs | 3 ++- 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/back/Contracts/DTOs/SpendingGroupDto.cs b/back/Contracts/DTOs/SpendingGroupDto.cs index cf03704..2adf558 100644 --- a/back/Contracts/DTOs/SpendingGroupDto.cs +++ b/back/Contracts/DTOs/SpendingGroupDto.cs @@ -5,4 +5,5 @@ public class SpendingGroupDto public Guid Id { get; set; } public string Name { get; set; } = string.Empty; public Guid UserId { get; set; } + public List ChangeRecords { get; set; } = new(); } \ No newline at end of file diff --git a/back/Infrastructure/Models/Changerecord.cs b/back/Infrastructure/Models/Changerecord.cs index 4f9a5e9..64b06c4 100644 --- a/back/Infrastructure/Models/Changerecord.cs +++ b/back/Infrastructure/Models/Changerecord.cs @@ -12,7 +12,7 @@ public class ChangeRecord public User User { get; set; } = null!; public Guid SpendingGroupId { get; set; } - public SpendingGroup SpendingGroup { get; set; } = null!; + public SpendingGroup? SpendingGroup { get; set; } public void Update(ChangeRecordDto changeRecordDto) { diff --git a/back/Infrastructure/Models/SpendingGroup.cs b/back/Infrastructure/Models/SpendingGroup.cs index b3d5d20..ec9d48e 100644 --- a/back/Infrastructure/Models/SpendingGroup.cs +++ b/back/Infrastructure/Models/SpendingGroup.cs @@ -7,4 +7,5 @@ public class SpendingGroup public Guid UserId { get; set; } public User User { get; set; } = null!; + public List ChangeRecords { get; set; } = new(); } \ No newline at end of file diff --git a/back/Infrastructure/Models/User.cs b/back/Infrastructure/Models/User.cs index add673c..469e15e 100644 --- a/back/Infrastructure/Models/User.cs +++ b/back/Infrastructure/Models/User.cs @@ -10,6 +10,7 @@ public class User public string Password { get; set; } = null!; public decimal Balance { get; set; } public List? SpendingGroups { get; set; } + public List? ChangeRecords { get; set; } public void Update(UserDto userDto) { diff --git a/back/Infrastructure/Repositories/SpendingGroupRepo.cs b/back/Infrastructure/Repositories/SpendingGroupRepo.cs index 38a69d0..d7e879e 100644 --- a/back/Infrastructure/Repositories/SpendingGroupRepo.cs +++ b/back/Infrastructure/Repositories/SpendingGroupRepo.cs @@ -46,6 +46,7 @@ public class SpendingGroupRepo : ISpendingGroupRepo using var context = _factory.CreateDbContext(); var group = await context.SpendingGroups + .Include(x => x.ChangeRecords) .FirstOrDefaultAsync(x => x.Id == search.Id || x.Name == search.Name); @@ -71,7 +72,7 @@ public class SpendingGroupRepo : ISpendingGroupRepo } } - return await query.Select(x => x.ToDto()).ToListAsync(); + return await query.Include(x => x.ChangeRecords).Select(x => x.ToDto()).ToListAsync(); } public async Task Update(SpendingGroupDto spendingGroup) diff --git a/back/Infrastructure/Support/Mappers/SpendingGroupMapper.cs b/back/Infrastructure/Support/Mappers/SpendingGroupMapper.cs index 94a39b6..1cb0585 100644 --- a/back/Infrastructure/Support/Mappers/SpendingGroupMapper.cs +++ b/back/Infrastructure/Support/Mappers/SpendingGroupMapper.cs @@ -10,7 +10,8 @@ public static class SpendingGroupMapper { Id = group.Id, Name = group.Name, - UserId = group.UserId + UserId = group.UserId, + ChangeRecords = group.ChangeRecords.Select(x => x.ToDto()).ToList() }; public static SpendingGroup ToModel(this SpendingGroupDto group) => new()