public bool Create(Config pNewConfig) { try { _db.Configs.Add(pNewConfig); _db.SaveChanges(); return true; } catch { return false; } }
public ActionResult Delete(int id, Config pNewConfig) { try { // TODO: Add delete logic here var check = new ConfigModel().Remove(id); if (check) return RedirectToAction("Index"); else return View(pNewConfig); } catch { return View(); } }
public bool Edit(int pId,Config pNewConfig) { try { var Object = _db.Configs.Find(pId); Object.Code = pNewConfig.Code; Object.Name = pNewConfig.Name; Object.Order = pNewConfig.Order; Object.IsActive = pNewConfig.IsActive; Object.LangId = pNewConfig.LangId; _db.SaveChanges(); return true; } catch { return false; } }
public ActionResult Create(Config pNewConfig,string Lang) { try { // TODO: Add insert logic here if (Lang == "Tiếng Việt") pNewConfig.LangId = 0; else pNewConfig.LangId = 1; var check = new ConfigModel().Create(pNewConfig); if (check) return RedirectToAction("Index"); else return View(pNewConfig); } catch { return View(pNewConfig); } }
public ActionResult Edit(int id, Config pNewConfig,string Lang) { try { // TODO: Add update logic here if (Lang == "Tiếng Việt") pNewConfig.LangId = 0; else pNewConfig.LangId = 1; var check = new ConfigModel().Edit(id,pNewConfig); if (check) return RedirectToAction("Index"); else return View(pNewConfig); } catch { return View(); } }