Exemplo n.º 1
0
        public ActionResult Create(tblLockerPC obj, string TypeSelect, bool SaveAndCountinue = false)
        {
            ViewBag.urlValue = url ?? Request.Url.PathAndQuery;

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Tạo dữ liệu không thành công. Hãy kiểm tra lại dữ liệu nhập vào");
                return View(obj);
            }

            obj.Id = Guid.NewGuid().ToString();

            var report = _tblLockerPCService.Create(obj);
            if (report.isSuccess)
            {
                WriteLog.Write(report, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.PCName, "tblLockerPC", ConstField.LockerCode, ActionConfigO.Create);

                TempData["Success"] = "Thêm mới thành công";

                if (SaveAndCountinue)
                {
                    return RedirectToAction("Create", "tblPC");
                }

                return Redirect(url);
            }
            else
            {
                ModelState.AddModelError("", "Tạo dữ liệu không thành công. Hãy kiểm tra lại dữ liệu nhập vào");
                return View(obj);
            }
        }
Exemplo n.º 2
0
        public ActionResult Update(tblLockerPC obj)
        {
            ViewBag.urlValue = url ?? Request.Url.PathAndQuery;

            if (!ModelState.IsValid)
            {
                return View(obj);
            }

            var oldobj = _tblLockerPCService.GetById(obj.Id);

            if (oldobj == null) return View(obj);

            oldobj.Description = obj.Description;
            oldobj.Active = obj.Active;
            oldobj.IPAddress = obj.IPAddress;
            oldobj.PCName = obj.PCName;

            var report = _tblLockerPCService.Update(oldobj);
            if (report.isSuccess)
            {
                WriteLog.Write(report, GetCurrentUser.GetUser(), oldobj.Id.ToString(), oldobj.PCName, "tblLockerPC", ConstField.LockerCode, ActionConfigO.Update);

                return Redirect(url);
            }
            else
            {
                ModelState.AddModelError("", "Tạo dữ liệu không thành công. Hãy kiểm tra lại dữ liệu nhập vào");
                return View(oldobj);
            }
        }
        public MessageReport Update(tblLockerPC obj)
        {
            MessageReport report;

            try
            {
                _tblLockerPCRepository.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);
        }