public ActionResult Update(BM_ApartmentUse obj, string key = "", int page = 1) { ViewBag.keyValue = key; ViewBag.PN = page; //Kiểm tra var oldObj = _BM_ApartmentUseService.GetById(obj.Id); if (oldObj == null) { ViewBag.Error = "Bản ghi không tồn tại"; return(View(obj)); } if (!ModelState.IsValid) { return(View(oldObj)); } //Gán giá trị oldObj.Name = obj.Name; oldObj.Ordering = obj.Ordering; //Thực hiện cập nhật var result = _BM_ApartmentUseService.Update(oldObj); if (result.isSuccess) { WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Name, "BM_ApartmentUse", ConstField.ResidentCode, ActionConfigO.Update); return(RedirectToAction("Index", new { page = page, key = key })); } else { ModelState.AddModelError("", result.Message); return(View(oldObj)); } }