0.1.0 #2

Merged
mfnefd merged 38 commits from dev into main 2024-12-09 04:27:05 +04:00
6 changed files with 8 additions and 3 deletions
Showing only changes of commit 6d734bbf79 - Show all commits

View File

@ -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<ChangeRecordDto> ChangeRecords { get; set; } = new();
}

View File

@ -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)
{

View File

@ -7,4 +7,5 @@ public class SpendingGroup
public Guid UserId { get; set; }
public User User { get; set; } = null!;
public List<ChangeRecord> ChangeRecords { get; set; } = new();
}

View File

@ -10,6 +10,7 @@ public class User
public string Password { get; set; } = null!;
public decimal Balance { get; set; }
public List<SpendingGroup>? SpendingGroups { get; set; }
public List<ChangeRecord>? ChangeRecords { get; set; }
public void Update(UserDto userDto)
{

View File

@ -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<SpendingGroupDto?> Update(SpendingGroupDto spendingGroup)

View File

@ -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()