Esempio n. 1
0
        public MessageReport DeleteById(string id, ref tblBlackList obj)
        {
            var re = new MessageReport();

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

            try
            {
                obj = GetById(id);
                if (obj != null)
                {
                    _tblBlackListRepository.Delete(n => n.Id.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);
        }
        public ActionResult Update(tblBlackList obj, int page = 1, string group = "", string key = "")
        {
            //
            ViewBag.PN         = page;
            ViewBag.groupValue = group;
            ViewBag.keyValue   = key;

            //Kiểm tra
            if (String.IsNullOrEmpty(obj.Plate) || String.IsNullOrWhiteSpace(obj.Plate))
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["enter_Number_plate"];
                return(View(obj));
            }

            var oldObj = _tblBlackListService.GetById(obj.Id.ToString());

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

            var objExisted = _tblBlackListService.GetByName_Plate(obj.Name, obj.Plate);

            if (objExisted.Where(n => !n.Id.Equals(obj.Id)).Any())
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                return(View(obj));
            }

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

            oldObj.Name        = obj.Name;
            oldObj.Description = obj.Description;
            oldObj.Plate       = obj.Plate;

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Plate, "tblBlackList", ConstField.ParkingCode, ActionConfigO.Update);

                return(RedirectToAction("Index", new { group = group, key = key, page = page, selectedId = obj.Id }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }
        /// <summary>
        /// Xóa
        /// </summary>
        /// <modified>
        /// Author              Date            Comments
        /// TrungNQ             01/09/2017      Tạo mới
        /// </modified>
        /// <param name="id">Id bản ghi</param>
        /// <returns></returns>
        public JsonResult Delete(string id)
        {
            var obj = new tblBlackList();

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Plate, "tblBlackList", ConstField.ParkingCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(tblBlackList obj, bool SaveAndCountinue = false, string group = "", string key = "")
        {
            ViewBag.groupValue = group;
            ViewBag.keyValue   = key;

            //Kiểm tra
            if (!ModelState.IsValid)
            {
                return(View(obj));
            }
            if (String.IsNullOrEmpty(obj.Plate) || String.IsNullOrWhiteSpace(obj.Plate))
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["enter_Number_plate"];
                return(View(obj));
            }

            var objExisted = _tblBlackListService.GetByName_Plate(obj.Name, obj.Plate);

            if (objExisted.Any())
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["exists_Number_plate"];
                return(View(obj));
            }

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Plate, "tblBlackList", ConstField.ParkingCode, ActionConfigO.Create);

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

                return(RedirectToAction("Index", new { group = group, key = key, selectedId = obj.Id }));
            }
            else
            {
                return(View(obj));
            }
        }
Esempio n. 5
0
        public MessageReport Create(tblBlackList obj)
        {
            var re = new MessageReport();

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

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