Exemplo n.º 1
0
        public async Task <int> Update(ExchangeBillUpdateDto dto, int id, string userId)
        {
            var oldExchangeBill = await _dbContext.ExchangeBills
                                  .Include(x => x.Transaction)
                                  .SingleOrDefaultAsync(x => x.Id == id);

            var updatedExchangeBill = _mapper.Map(dto, oldExchangeBill);

            updatedExchangeBill.UpdateAt  = DateTime.Now;
            updatedExchangeBill.UpdatedBy = userId;

            _dbContext.ExchangeBills.Update(updatedExchangeBill);

            await _dbContext.SaveChangesAsync();

            return(updatedExchangeBill.Id);
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Update([FromBody] ExchangeBillUpdateDto dto, int id)
 => await GetResponse(async (userId) =>
                      new ApiResponseViewModel(true, "ExchangeBill Updated Successfully", await _service.Update(dto, id, userId)));