public ActionResult Update(tblAccessLine obj) { ViewBag.urlValue = url ?? Request.Url.PathAndQuery; //Danh sách sử dụng ViewBag.PCs = GetPCList(); ViewBag.Communications = GetCommunicationList(); ViewBag.LineTypes = GetLineList(); //Kiểm tra var oldObj = _tblAccessLineService.GetById(obj.LineID); 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.DownloadTime = obj.DownloadTime; oldObj.Baudrate = obj.Baudrate; oldObj.CommunicationType = obj.CommunicationType; oldObj.Comport = obj.Comport; oldObj.Inactive = obj.Inactive; oldObj.LineTypeID = obj.LineTypeID; oldObj.PCID = obj.PCID; oldObj.LineTypeID = obj.LineTypeID; oldObj.LineName = obj.LineName; //Thực hiện cập nhật var result = _tblAccessLineService.Update(oldObj); if (result.isSuccess) { WriteLog.Write(result, GetCurrentUser.GetUser(), oldObj.LineID.ToString(), oldObj.LineName, "tblAccessLine", ConstField.AccessControlCode, ActionConfigO.Update); return(Redirect(url)); } else { ModelState.AddModelError("", result.Message); return(View(oldObj)); } }
public MessageReport Update(tblAccessLine obj) { MessageReport report; try { _tblAccessLineRepository.Update(obj); Save(); report = new MessageReport(true, "Cập nhật thành công"); } catch (Exception ex) { report = new MessageReport(false, ex.InnerException != null ? ex.InnerException.ToString() : ex.Message); } return(report); }
public ActionResult Create(tblAccessLine obj, bool SaveAndCountinue = false) { ViewBag.urlValue = url ?? Request.Url.PathAndQuery; //Danh sách sử dụng ViewBag.PCs = GetPCList(); ViewBag.Communications = GetCommunicationList(); ViewBag.LineTypes = GetLineList(); //Kiểm tra if (!ModelState.IsValid) { return(View(obj)); } //Gán giá trị obj.LineID = Guid.NewGuid(); //Thực hiện thêm mới var result = _tblAccessLineService.Create(obj); if (result.isSuccess) { WriteLog.Write(result, GetCurrentUser.GetUser(), obj.LineID.ToString(), obj.LineName, "tblAccessLine", ConstField.AccessControlCode, ActionConfigO.Create); if (SaveAndCountinue) { TempData["Success"] = result.Message; return(RedirectToAction("Create")); } return(Redirect("Index")); } else { return(View(obj)); } }