public ActionResult Create([DataSourceRequest] DataSourceRequest request, Tbl_AboutUs model) { using (var db = new ProjectWebEntities()) { try { if (model != null) { // update if (model.Id != 0) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); } } //Xóa cache CacheHelper.ClearAllOutputCache(); } catch (Exception ex) { _logger.Error("An Error Happened! ", ex); } TempData["ThanhCong"] = "Cập nhật thành công !"; return(RedirectToAction("Create", "AboutUs")); } }
public ActionResult Create(int id = 1) { using (var db = new ProjectWebEntities()) { var model = new Tbl_AboutUs(); if (id != 0) { model = db.Tbl_AboutUs.SingleOrDefault(t => t.Id == id); } return(View(model)); } }