public JsonResult Action(KindOfDebtsActionModel model) { JsonResult json = new JsonResult(); var result = false; if (model.ID > 0) // we are trying to edit a record { var kindOfDebts = kindOfDebtsServices.GetKindsOfDebtsByID(model.ID); kindOfDebts.Name = model.Name; result = kindOfDebtsServices.UpdateKindsOfDebts(kindOfDebts); } else // we are trying to create a record { KindOfDebts kindOfDebts = new KindOfDebts(); kindOfDebts.Name = model.Name; result = kindOfDebtsServices.SaveKindsOfDebts(kindOfDebts); } if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to perform action on KindOfDebts" }; } return(json); }
public ActionResult Delete(int ID) { KindOfDebtsActionModel model = new KindOfDebtsActionModel(); var kindOfDebts = kindOfDebtsServices.GetKindsOfDebtsByID(ID); model.ID = kindOfDebts.ID; return(PartialView("_Delete", model)); }
public ActionResult Action(int?ID) { KindOfDebtsActionModel model = new KindOfDebtsActionModel(); if (ID.HasValue) // we are trying to edit a record { var kindOfDebts = kindOfDebtsServices.GetKindsOfDebtsByID(ID.Value); model.ID = kindOfDebts.ID; model.Name = kindOfDebts.Name; } return(PartialView("_Action", model)); }
public JsonResult Delete(KindOfDebtsActionModel model) { JsonResult json = new JsonResult(); var result = false; var kindOfDebts = kindOfDebtsServices.GetKindsOfDebtsByID(model.ID); result = kindOfDebtsServices.DeleteKindsOfDebts(kindOfDebts); if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to perform action on Kinds" }; } return(json); }