public async Task UpdateAsync(Guid settlementId, Guid userId, string name, string description) { var user = await _userRepository.HasAccessToSettlement(userId, settlementId); var settlement = await _settlementRepository.GetSettlementOrFailAsync(settlementId); settlement.SetName(name); settlement.SetDescription(description); manager.Settle(settlement); await _settlementRepository.UpdateSettlementAsync(settlement); }
public static async Task <IEnumerable <Expense> > GetExpensesOrFailAsync(this ISettlementRepository repository, Guid settlementId, Guid currentUserId) { var settlement = await repository.GetSettlementOrFailAsync(settlementId); var userExpenses = settlement.GetExpenses(currentUserId); if (userExpenses == null) { throw new Exception($"User with id: '{currentUserId}' have not expenses in settlement with id: {settlementId}"); } return(userExpenses); }