public ActionResult Delete(int ID) { SavingsActionModel model = new SavingsActionModel(); var savings = savingsServices.GetSavingsByID(ID); model.ID = savings.ID; return(PartialView("_Delete", model)); }
public JsonResult Action(SavingsActionModel model) { model.Currencies = currencyServices.GetAllCurrencies(); JsonResult json = new JsonResult(); var result = false; if (model.ID > 0) // we are trying to edit a record { var savings = savingsServices.GetSavingsByID(model.ID); savings.Type = model.Type; savings.Name = model.Name; savings.Price = model.Price; savings.DateEnd = model.DateEnd; savings.Currency = model.Currency; result = savingsServices.UpdateSavings(savings); } else // we are trying to create a record { Savings savings = new Savings(); savings.Type = model.Type; savings.Name = model.Name; savings.Price = model.Price; savings.DateEnd = model.DateEnd; savings.Currency = model.Currency; result = savingsServices.SaveSavings(savings); } if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to perform action on savings" }; } return(json); }
public JsonResult Delete(SavingsActionModel model) { JsonResult json = new JsonResult(); var result = false; var savings = savingsServices.GetSavingsByID(model.ID); result = savingsServices.DeleteSavings(savings); if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to perform action on savings" }; } return(json); }
public ActionResult Action(int?ID) { SavingsActionModel model = new SavingsActionModel(); model.Currencies = currencyServices.GetAllCurrencies(); if (ID.HasValue) // we are trying to edit a record { var savings = savingsServices.GetSavingsByID(ID.Value); model.ID = savings.ID; model.Type = savings.Type; model.Name = savings.Name; model.Price = savings.Price; model.DateEnd = savings.DateEnd; model.Currency = savings.Currency; } return(PartialView("_Action", model)); }