public ActionResult Save(tblCatalog oCatalog) { if (ModelState.IsValid) { try { bool Add_Flg = new CommonBL().isNewEntry(oCatalog.Id); if (Add_Flg) { new CatalogBL().Create(oCatalog); } else { new CatalogBL().Update(oCatalog); } //TempData["successmsg"] = CommonMsg.Success_Update(EntityNames.Company); return(RedirectToAction("ManageCatalog", new { id = oCatalog.Id })); } catch (Exception ex) { //TempData["errormsg"] = CommonMsg.Error(); return(RedirectToAction("Index")); } } else { //TempData["errormsg"] = CommonMsg.Error(); return(RedirectToAction("Index")); } }
public ActionResult ThemCalg(tblCatalog cal) { if (ModelState.IsValid) { data.tblCatalogs.InsertOnSubmit(cal); data.SubmitChanges(); } return(RedirectToAction("Catalog")); }
public ActionResult XNLuuCalg(string id) { tblCatalog cal = data.tblCatalogs.SingleOrDefault(n => n.id == id); if (ModelState.IsValid) { UpdateModel(cal); data.SubmitChanges(); } return(RedirectToAction("Catalog")); }
public ActionResult EditCalg(string id) { tblCatalog cal = data.tblCatalogs.SingleOrDefault(n => n.id == id); if (cal == null) { Response.StatusCode = 404; return(null); } return(View(cal)); }
public PartialViewResult ManageCatalog(int id) { tblCatalog catalog = new tblCatalog(); if (id != 0) { catalog = new CatalogBL().GetById(id); } ViewBag.Types = new CatalogTypeBL().GetAllCatalogTypes(); return(PartialView("_Manage", catalog)); }
public ActionResult XNXoaC(string id) { tblCatalog cal = data.tblCatalogs.SingleOrDefault(n => n.id == id); if (cal == null) { Response.StatusCode = 404; return(null); } data.tblCatalogs.DeleteOnSubmit(cal); data.SubmitChanges(); return(RedirectToAction("Catalog")); }
public void Create(tblCatalog oCatalog) { try { using (var ctx = new CRUDSampleEntities()) { ctx.tblCatalogs.Add(oCatalog); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Update(tblCatalog oCatalog) { try { using (var ctx = new CRUDSampleEntities()) { ctx.Entry(oCatalog).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Delete(int id) { try { using (var ctx = new CRUDSampleEntities()) { tblCatalog oCatalog = ctx.tblCatalogs.Where(c => c.Id == id).FirstOrDefault(); ctx.tblCatalogs.Remove(oCatalog); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public JsonResult IsBarCodeUnique(tblCatalog catalog) { return(Json(!new CatalogBL().IsCatalogExist(catalog.CatalogName, catalog.Barcode))); }