public ExpenseUpdateAccountUpdateModel Edit(ExpenseAddModel model) { var expense = Find(model.ExpenseId); if (expense == null) { return(null); } var returnModel = new ExpenseUpdateAccountUpdateModel { IsApproved = expense.IsApproved, PrevAmount = expense.ExpenseAmount, CurrentAmount = model.ExpenseAmount, PrevAccountId = expense.AccountId, CurrentAccountId = model.AccountId }; expense.ExpenseDate = model.ExpenseDate; expense.ExpenseAmount = model.ExpenseAmount; expense.ExpenseCategoryId = model.ExpenseCategoryId; expense.ExpenseFor = model.ExpenseFor; Update(expense); return(returnModel); }
public ExpenseUpdateAccountUpdateModel Edit(ExpenseTransportationDetailsModel model) { var expenseTransportation = Context.ExpenseTransportation .Include(e => e.ExpenseTransportationList) .FirstOrDefault(e => e.ExpenseTransportationId == model.ExpenseTransportationId); if (expenseTransportation == null) { return(null); } var returnModel = new ExpenseUpdateAccountUpdateModel { IsApproved = expenseTransportation.IsApproved, PrevAmount = expenseTransportation.TotalExpense, CurrentAmount = model.TotalExpense, PrevAccountId = expenseTransportation.AccountId, CurrentAccountId = model.AccountId }; expenseTransportation.ExpenseTransportationId = model.ExpenseTransportationId; expenseTransportation.CustomerId = model.CustomerId; expenseTransportation.TotalExpense = model.TotalExpense; expenseTransportation.ExpenseNote = model.ExpenseNote; expenseTransportation.ExpenseDate = model.ExpenseDate; expenseTransportation.ExpenseTransportationList = model.ExpenseTransportationList.Select(e => _mapper.Map <ExpenseTransportationList>(e)).ToList(); Context.ExpenseTransportation.Update(expenseTransportation); return(returnModel); }