public MessageReport DeleteById(string id, ref tblFtpAccount obj)
        {
            var re = new MessageReport();

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

            try
            {
                obj = GetById(id);
                if (obj != null)
                {
                    _tblFtpAccountRepository.Delete(n => n.Id == 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);
        }
Exemplo n.º 2
0
        /// <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 tblFtpAccount();

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

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

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult Update(tblFtpAccount obj, int page = 1, string group = "", string key = "")
        {
            //
            ViewBag.PN         = page;
            ViewBag.groupValue = group;
            ViewBag.keyValue   = key;

            //Kiểm tra
            var oldObj = _tblFtpAccountService.GetById(obj.Id);

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

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

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

            oldObj.FtpHost = obj.FtpHost;
            oldObj.FtpPass = obj.FtpPass;
            oldObj.FtpUser = obj.FtpUser;
            oldObj.FtpPass = CryptoProvider.SimpleEncryptWithPassword(obj.FtpPass, SecurityModel.Session_Key);
            //oldObj.SortOrder = obj.SortOrder;

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id, obj.FtpHost, "tblFtpAccount", 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));
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(tblFtpAccount 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.IsNullOrWhiteSpace(obj.FtpHost))
            {
                ModelState.AddModelError("FtpHost", FunctionHelper.GetLocalizeDictionary("Home", "notification")["enter_name"]);
                return(View(obj));
            }

            //Gán giá trị
            obj.Id      = Common.GenerateId();
            obj.FtpPass = CryptoProvider.SimpleEncryptWithPassword(obj.FtpPass, SecurityModel.Session_Key);

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id, obj.FtpHost, "tblFtpAccount", 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));
            }
        }
        public MessageReport Create(tblFtpAccount obj)
        {
            var re = new MessageReport();

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

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