コード例 #1
0
        public MessageReport DeleteById(string id, ref tblLane obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(Guid.Parse(id));
                if (obj != null)
                {
                    _tblLaneRepository.Delete(n => n.LaneID.ToString() == id);

                    Save();

                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
コード例 #2
0
        public JsonResult Delete(string id)
        {
            var obj = new tblLane();

            var result = _tblLaneService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.LaneID.ToString(), obj.LaneName, "tblLane", ConstField.ParkingCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public ActionResult Create(tblLane obj, string key, string pc, string group = "", bool SaveAndCountinue = false)
        {
            ViewBag.LaneType    = FunctionHelper.LaneTypes1();
            ViewBag.CheckPlates = FunctionHelper.CheckBSType();
            ViewBag.PCs         = GetPCList();

            ViewBag.keyValue   = key;
            ViewBag.pcValue    = pc;
            ViewBag.groupValue = group;

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

            if (string.IsNullOrWhiteSpace(obj.LaneName))
            {
                ModelState.AddModelError("LaneName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Lane_Name"]);
                return(View(obj));
            }

            var existed = _tblLaneService.GetByName(obj.LaneName);

            if (existed != null)
            {
                ModelState.AddModelError("LaneName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Lane_Name_already_exists"]);
                return(View(obj));
            }

            obj.LaneID = Guid.NewGuid();

            //Thực hiện thêm mới
            var result = _tblLaneService.Create(obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.LaneID.ToString(), obj.LaneName, "tblLane", ConstField.ParkingCode, ActionConfigO.Create);

                if (SaveAndCountinue)
                {
                    TempData["Success"] = result.Message;
                    return(RedirectToAction("Create", new { group = group, key = key, pc = pc, selectedId = obj.LaneID }));
                }

                return(RedirectToAction("Index", new { group = group, key = key, pc = pc, selectedId = obj.LaneID }));
            }
            else
            {
                return(View(obj));
            }
        }
コード例 #4
0
        public MessageReport Create(tblLane obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                _tblLaneRepository.Add(obj);

                Save();

                re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["addSuccess"];
                re.isSuccess = true;
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
コード例 #5
0
        public ActionResult Update(tblLane obj, int page = 1, string key = "", string pc = "", string group = "")
        {
            ViewBag.LaneType    = FunctionHelper.LaneTypes1();
            ViewBag.CheckPlates = FunctionHelper.CheckBSType();
            ViewBag.PCs         = GetPCList();

            ViewBag.keyValue   = key;
            ViewBag.pcValue    = pc;
            ViewBag.PN         = page;
            ViewBag.groupValue = group;

            var oldObj = _tblLaneService.GetById(obj.LaneID);

            if (oldObj == null)
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                return(View(obj));
            }

            if (string.IsNullOrWhiteSpace(obj.LaneName))
            {
                ModelState.AddModelError("LaneName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Lane_Name"]);
                return(View(oldObj));
            }

            var existed = _tblLaneService.GetByName_Id(obj.LaneName, obj.LaneID);

            if (existed != null)
            {
                ModelState.AddModelError("LaneName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Lane_Name_already_exists"]);
                return(View(oldObj));
            }

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

            oldObj.LaneName           = obj.LaneName;
            oldObj.LaneType           = obj.LaneType;
            oldObj.PCID               = obj.PCID;
            oldObj.C1                 = obj.C1;
            oldObj.C2                 = obj.C2;
            oldObj.C3                 = obj.C3;
            oldObj.C4                 = obj.C4;
            oldObj.C5                 = obj.C5;
            oldObj.C6                 = obj.C6;
            oldObj.AccessForEachSide  = obj.AccessForEachSide;
            oldObj.CheckPlateLevelIn  = obj.CheckPlateLevelIn;
            oldObj.CheckPlateLevelOut = obj.CheckPlateLevelOut;
            oldObj.IsFree             = obj.IsFree;
            oldObj.IsLoop             = obj.IsLoop;
            oldObj.Inactive           = obj.Inactive;
            oldObj.IsLED              = obj.IsLED;
            oldObj.IsPrint            = obj.IsPrint;
            //oldObj.SortOrder = obj.SortOrder;

            //Thực hiện cập nhật
            var result = _tblLaneService.Update(oldObj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.LaneID.ToString(), obj.LaneName, "tblLane", ConstField.ParkingCode, ActionConfigO.Update);

                return(RedirectToAction("Index", new { group = group, page = page, key = key, pc = pc, selectedId = obj.LaneID }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }