public async Task <IActionResult> UpdateStatusOfTransaction(UpdateStatusOfTransactionVm updateTransactionVm) { ServiceResponse <Transaction> response = await _service.UpdateStatusOfTransaction(updateTransactionVm); if (response.Data == null) { return(NotFound()); } return(Ok(response)); }
// Update status of transaction public async Task <ServiceResponse <Transaction> > UpdateStatusOfTransaction(UpdateStatusOfTransactionVm updateTransactionVm) { ServiceResponse <Transaction> serviceResponse = new ServiceResponse <Transaction>(); try { var transaction = await _context.Transactions.FirstOrDefaultAsync(t => t.Id == updateTransactionVm.Id); transaction.Status = updateTransactionVm.Status; serviceResponse.Data = transaction; serviceResponse.Message = "Status of you're transaction has been updated"; _context.Transactions.Update(transaction); await _context.SaveChangesAsync(); } catch (Exception ex) { serviceResponse.Success = false; serviceResponse.Message = ex.Message; } return(serviceResponse); }