0.1.0 #2
@ -5,4 +5,5 @@ public class SpendingGroupDto
|
|||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public Guid UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
|
public List<ChangeRecordDto> ChangeRecords { get; set; } = new();
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ public class ChangeRecord
|
|||||||
public User User { get; set; } = null!;
|
public User User { get; set; } = null!;
|
||||||
|
|
||||||
public Guid SpendingGroupId { get; set; }
|
public Guid SpendingGroupId { get; set; }
|
||||||
public SpendingGroup SpendingGroup { get; set; } = null!;
|
public SpendingGroup? SpendingGroup { get; set; }
|
||||||
|
|
||||||
public void Update(ChangeRecordDto changeRecordDto)
|
public void Update(ChangeRecordDto changeRecordDto)
|
||||||
{
|
{
|
||||||
|
@ -7,4 +7,5 @@ public class SpendingGroup
|
|||||||
|
|
||||||
public Guid UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
public User User { get; set; } = null!;
|
public User User { get; set; } = null!;
|
||||||
|
public List<ChangeRecord> ChangeRecords { get; set; } = new();
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ public class User
|
|||||||
public string Password { get; set; } = null!;
|
public string Password { get; set; } = null!;
|
||||||
public decimal Balance { get; set; }
|
public decimal Balance { get; set; }
|
||||||
public List<SpendingGroup>? SpendingGroups { get; set; }
|
public List<SpendingGroup>? SpendingGroups { get; set; }
|
||||||
|
public List<ChangeRecord>? ChangeRecords { get; set; }
|
||||||
|
|
||||||
public void Update(UserDto userDto)
|
public void Update(UserDto userDto)
|
||||||
{
|
{
|
||||||
|
@ -46,6 +46,7 @@ public class SpendingGroupRepo : ISpendingGroupRepo
|
|||||||
using var context = _factory.CreateDbContext();
|
using var context = _factory.CreateDbContext();
|
||||||
|
|
||||||
var group = await context.SpendingGroups
|
var group = await context.SpendingGroups
|
||||||
|
.Include(x => x.ChangeRecords)
|
||||||
.FirstOrDefaultAsync(x => x.Id == search.Id
|
.FirstOrDefaultAsync(x => x.Id == search.Id
|
||||||
|| x.Name == search.Name);
|
|| 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)
|
public async Task<SpendingGroupDto?> Update(SpendingGroupDto spendingGroup)
|
||||||
|
@ -10,7 +10,8 @@ public static class SpendingGroupMapper
|
|||||||
{
|
{
|
||||||
Id = group.Id,
|
Id = group.Id,
|
||||||
Name = group.Name,
|
Name = group.Name,
|
||||||
UserId = group.UserId
|
UserId = group.UserId,
|
||||||
|
ChangeRecords = group.ChangeRecords.Select(x => x.ToDto()).ToList()
|
||||||
};
|
};
|
||||||
public static SpendingGroup ToModel(this SpendingGroupDto group)
|
public static SpendingGroup ToModel(this SpendingGroupDto group)
|
||||||
=> new()
|
=> new()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user