public async Task <int> UpdateAsync(int id, SalesReceiptModel model) { using (var transaction = DbContext.Database.BeginTransaction()) { try { salesReceiptLogic.UpdateAsync(id, model); } catch (Exception e) { transaction.Rollback(); throw new Exception(e.Message); } } return(await DbContext.SaveChangesAsync()); }
public async Task <int> UpdateAsync(int id, SalesReceiptModel model) { using (var transaction = DbContext.Database.BeginTransaction()) { try { foreach (var item in model.SalesReceiptDetails) { var updateTotalPaid = DbContext.SalesInvoices.FirstOrDefault(x => x.Id == item.SalesInvoiceId); updateTotalPaid.TotalPaid = item.Paid; } salesReceiptLogic.UpdateAsync(id, model); } catch (Exception e) { transaction.Rollback(); throw new Exception(e.Message); } } return(await DbContext.SaveChangesAsync()); }