public ActionResult Create(tblLockerSelfHost obj, string key, string pcs, bool SaveAndCountinue = false) { ViewBag.keyValue = key; ViewBag.pcsValue = pcs; ViewBag.pcsList = _tblLockerPCService.GetAllActive(); if (!ModelState.IsValid) { return(View(obj)); } obj.Id = Common.GenerateId(); obj.DateCreated = DateTime.Now; var result = _tblLockerSelfHostService.Create(obj); if (result.isSuccess) { WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Address, "tblLockerSelfHost", ConstField.LockerCode, ActionConfigO.Create); if (SaveAndCountinue) { TempData["Success"] = result.Message; return(RedirectToAction("Create", new { key = key, pcs = pcs, selectedId = obj.Id, page = 1 })); } return(RedirectToAction("Index", new { key = key, pcs = pcs, selectedId = obj.Id, page = 1 })); } else { ModelState.AddModelError("", result.Message); return(View(obj)); } }
public ActionResult Update(tblLockerSelfHost obj, string key, string pcs, int page = 1) { ViewBag.keyValue = key; ViewBag.pcsValue = pcs; ViewBag.PN = page; ViewBag.pcsList = _tblLockerPCService.GetAllActive(); if (!ModelState.IsValid) { return(View(obj)); } var oldObj = _tblLockerSelfHostService.GetById(obj.Id); if (oldObj == null) { return(View(obj)); } oldObj.Address = obj.Address; oldObj.Hostname = obj.Hostname; oldObj.PCID = obj.PCID; var result = _tblLockerSelfHostService.Update(oldObj); if (result.isSuccess) { var cuuser = GetCurrentUser.GetUser(); //Log for hệ thống WriteLog.Write(result, cuuser, oldObj.Id.ToString(), oldObj.Address, "tblLockerSelfHost", ConstField.LockerCode, ActionConfigO.Update); return(RedirectToAction("Index", new { key = key, pcs = pcs, selectedId = obj.Id, page = page })); } else { ModelState.AddModelError("", result.Message); return(View(obj)); } }
public MessageReport Create(tblLockerSelfHost obj) { var re = new MessageReport(); re.Message = "Error"; re.isSuccess = false; try { _tblLockerSelfHostRepository.Add(obj); Save(); re.Message = "Thêm mới thành công"; re.isSuccess = true; } catch (Exception ex) { re.Message = ex.Message; re.isSuccess = false; } return(re); }