public ActionResult SubmitSavings(SavingsFormViewModel viewModelObj) { if (viewModelObj.Id.IsNotNull()) { return(UpdateSavings(viewModelObj)); } else { return(AddSavings(viewModelObj)); } }
private ActionResult UpdateSavings(SavingsFormViewModel viewModelObj) { var savingsObj = BaseRepository.GetById(viewModelObj.Id.ToInt()); savingsObj.Description = viewModelObj.Description; savingsObj.LastModifiedDate = DateTime.Now; BaseRepository.Context.SaveChanges(); return(Redirect("Savings")); }
private ActionResult AddSavings(SavingsFormViewModel viewModelObj) { BaseRepository.Insert(new Models.DataBase.Savings { User_Id = WebHelpers.GetSession().UserId, Description = viewModelObj.Description, DateCreated = DateTime.Now, LastModifiedDate = DateTime.Now }); return(Redirect("Savings")); }
public ActionResult AddTransaction(SavingsFormViewModel savingsObj) { BaseRepository.Context.Savings_Transactions.Add(new Savings_Transactions { Savings_Id = savingsObj.Id.ToInt(), User_Id = WebHelpers.GetSession().UserId, Description = savingsObj.TransactionForm.Description, InputDate = savingsObj.TransactionForm.InputDate.ToDateTime(), TransactionDate = DateTime.Now, Type = savingsObj.TransactionForm.Type, Value = savingsObj.TransactionForm.Value.MoneyToDecimal() }); BaseRepository.Context.SaveChanges(); CalculateSavings(savingsObj.Id.ToInt()); return(Redirect($"EditSavings?id={savingsObj.Id}")); }