public ActionResult Delete(int ID) { SupplierActionModel model = new SupplierActionModel(); var mainMenu = services.GetSupplierByID(ID); model.SupplierID = mainMenu.SupplierID; return(PartialView("_Delete", model)); }
public ActionResult AddAndEdit(int?ID) { SupplierActionModel model = new SupplierActionModel(); if (ID.HasValue) { var suppler = services.GetSupplierByID(ID.Value); model.SupplierID = suppler.SupplierID; model.SupplierName = suppler.SupplierName; } return(PartialView("_AddAndEdit", model)); }
public JsonResult Delete(SupplierActionModel model) { JsonResult json = new JsonResult(); var result = false; var supplier = services.GetSupplierByID(model.SupplierID); result = services.DeleteSupplier(supplier); if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to perform any action" }; } return(json); }
public JsonResult AddAndEdit(SupplierActionModel model) { JsonResult json = new JsonResult(); var result = false; if (model.SupplierID > 0) { var supplier = services.GetSupplierByID(model.SupplierID); supplier.SupplierName = model.SupplierName; supplier.UpdatedAt = DateTime.Now; result = services.UpdateSupplier(supplier); } else { Supplier supplier = new Supplier(); supplier.SupplierName = model.SupplierName; supplier.UpdatedAt = DateTime.Now; result = services.SaveSupplier(supplier); } if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to perform any action" }; } return(json); }