예제 #1
0
        public async Task UpdateAsync(int settlementId, CreateSettlementDto dto)
        {
            var settlement = await _settlementRepository.FindByIdAsync(settlementId);

            if (settlement == null)
            {
                throw new ResourceNotFoundException();
            }

            MapToInstance(dto, settlement);

            await _settlementRepository.UpdateAsync(settlement);
        }
        public async Task ApproveAsync(string settlementId, string userId)
        {
            Settlement settlement = await GetByIdAsync(settlementId);

            if (settlement.Status != SettlementStatus.New)
            {
                throw new InvalidOperationException("Only new settlement can be approved");
            }

            settlement.Status = SettlementStatus.Approved;

            await _settlementRepository.UpdateAsync(settlement);

            _log.InfoWithDetails("Settlement approved", new { settlement.Id, userId });
        }