public void updateDisablePromotionProgram(Tbl_PromotionProgram input) { using (var Db = new ProjectWebEntities()) { try { var model = Db.Tbl_PromotionProgram.Find(input.Id); model.IsDisable = input.IsDisable; Db.Entry(model).State = EntityState.Modified; Db.SaveChanges(); // Write log system--------- Db.pr_LogSystem_save("Cập nhật dữ liệu(ID = " + model.Id + ")", "Cập nhật", "Promotion", User.Identity.Name); } catch (Exception ex) { logger.Error("An Error Happened! ", ex); } } }
public ActionResult Create(Tbl_PromotionProgram model) { using (var Db = new ProjectWebEntities()) { try { if (model != null) { if (model.Id == 0) { try { Db.Tbl_PromotionProgram.Add(model); Db.SaveChanges(); } catch (Exception ex) { logger.Error("An Error Happened! ", ex); } } else // update { try { Db.Entry(model).State = EntityState.Modified; Db.SaveChanges(); } catch (Exception ex) { logger.Error("An Error Happened! ", ex); } } } } catch (Exception ex) { logger.Error("An Error Happened! ", ex); } return(RedirectToAction("Index", "PromotionProgram")); } }
public ActionResult PromotionProgram_Destroy([DataSourceRequest] DataSourceRequest request, Tbl_PromotionProgram model) { using (var Db = new ProjectWebEntities()) { try { var m = Db.Tbl_PromotionProgram.Find(model.Id); if (model != null) { try { m.IsStatus = GlobalVariables.status_Deleted; m.DateDelete = DateTime.Now; Db.Entry(m).State = EntityState.Modified; Db.SaveChanges(); Db.pr_LogSystem_save("Xóa dữ liệu(ID = " + model.Id + ")", "Xóa", "Promotion", User.Identity.Name); } catch (Exception ex) { // Write log system--------- Db.pr_LogSystem_save("Xóa dữ liệu(ID = " + model.Id + ")", "Xóa", "Promotion", User.Identity.Name); logger.Error("An Error Happened! ", ex); } } } catch (Exception ex) { logger.Error("An Error Happened! ", ex); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); } }