public async Task <ActionResult <RevenueDto> > Get(int id)
        {
            var revenue = await _revenueRepository.GetAsync(id);

            if (revenue == null)
            {
                return(BadRequest(new ErrorMessage("Revenue not found")));
            }
            return(ConvertToDto(revenue));
        }
示例#2
0
        public async Task <Revenue> UpdateAsync(int revenueId, InsertUpdateRevenueCommand command)
        {
            var revenue = await _revenueRepository.GetAsync(revenueId);

            if (revenue == null)
            {
                throw new EntityNotFoundException("Revenue");
            }

            revenue.AccrualDate     = command.AccrualDate;
            revenue.Amount          = command.Amount;
            revenue.Description     = command.Description;
            revenue.InvoiceId       = command.InvoiceId;
            revenue.TransactionDate = command.TransactionDate;

            await _revenueRepository.SaveChangesAsync();

            return(revenue);
        }