예제 #1
0
        protected ActionResult UpdateEntity <T>() where T : class, IBaseTable, new()
        {
            T model = new T();

            TryUpdateModel(model);

            string result = "";

            if (!ModelState.IsValid)
            {
                result = "验证失败:" + ModelState.Values.First(p => p.Errors.Count > 0).Errors.First().ErrorMessage;
                return(Json(JSHelper.JsonMessage(result, false), JsonRequestBehavior.AllowGet));
            }

            BaseRepository repository = new BaseRepository();

            result = repository.Update <T>(model);

            if (!string.IsNullOrEmpty(result))
            {
                return(Json(JSHelper.JsonMessage(result, false), JsonRequestBehavior.AllowGet));
            }

            return(Json(JSHelper.JsonMessage("操作成功", true), JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult UpdateRoles(int id, tbPermission[] roles)
        {
            string result = "";
            var    rsp    = new AuthorityRepository();

            result = rsp.Delete <tbPermission>(p => p.roleID == id);
            if (!string.IsNullOrEmpty(result))
            {
                return(Json(JSHelper.JsonMessage(result, false), JsonRequestBehavior.AllowGet));
            }

            if (roles != null)
            {
                foreach (var item in roles)
                {
                    item.roleID = id;
                    result      = rsp.Inset <tbPermission>(item);
                    if (!string.IsNullOrEmpty(result))
                    {
                        return(Json(JSHelper.JsonMessage(result, false), JsonRequestBehavior.AllowGet));
                    }
                }
            }

            return(Json(JSHelper.JsonMessage("操作成功", true), JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult Update(string raiserID, int vaccineID, DateTime realyInjectionDate)
        {
            var result = VaccinePlan.Injection(raiserID, vaccineID, realyInjectionDate);

            if (!string.IsNullOrEmpty(result))
            {
                return(Json(JSHelper.JsonMessage(result, false), JsonRequestBehavior.AllowGet));
            }
            return(Json(JSHelper.JsonMessage("保存成功", true), JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult Check(int id, int value)
        {
            var result = new BaseRepository().UpdateProperty <tbFeedGrant>(p => p.ID == id, "checkState", value);

            if (!string.IsNullOrEmpty(result))
            {
                return(Json(JSHelper.JsonMessage(result), JsonRequestBehavior.AllowGet));
            }

            return(Json(JSHelper.JsonMessage("操作完成", true), JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        protected ActionResult DeleteEntity <T>(int id) where T : class, IBaseTable
        {
            BaseRepository repository = new BaseRepository();
            var            result     = repository.Delete <T>(p => p.ID == id);

            if (!string.IsNullOrEmpty(result))
            {
                return(Json(JSHelper.JsonMessage(result, false), JsonRequestBehavior.AllowGet));
            }

            return(Json(JSHelper.JsonMessage("操作成功", true), JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        protected ActionResult NoAuthorize(string responseType, string responseText)
        {
            ActionResult result;

            if (!string.IsNullOrEmpty(responseType))
            {
                responseType = responseType.ToLower();
            }

            switch (responseType)
            {
            case "json":
                result =
                    new JsonResult {
                    Data = JSHelper.JsonMessage(responseText, false, 0),
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
                break;

            case "script":
                result =
                    new JavaScriptResult {
                    Script = JSHelper.ShowError(responseText)
                };
                break;

            case "content":
                result =
                    new ContentResult {
                    Content = string.Format("{0}", responseText)
                };
                break;

            case "view":
                result = new RedirectResult(string.Format("/Logon/Error?text={0}", responseText));
                //new PartialViewResult { ViewName = "", ViewData = new ViewDataDictionary(new {text = responseText }) };
                break;

            default:
                result =
                    new JsonResult
                {
                    Data = JSHelper.JsonMessage(responseText, false, 0),
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
                //new ContentResult { Content = responseText };
                //new ContentResult { Content = string.Format("{0},{1}", controllerName, actionName) };
                break;
            }

            return(result);
        }
예제 #7
0
        protected ActionResult UpdateProperty <T>(int id, string property, object value) where T : class, IBaseTable, new()
        {
            string         result     = "";
            BaseRepository repository = new BaseRepository();

            result = repository.UpdateProperty <T>(p => p.ID == id, property, value);

            if (!string.IsNullOrEmpty(result))
            {
                return(Json(JSHelper.JsonMessage(result, false), JsonRequestBehavior.AllowGet));
            }

            return(Json(JSHelper.JsonMessage("操作成功", true), JsonRequestBehavior.AllowGet));
        }
예제 #8
0
        public ActionResult ChangePassword()
        {
            var p0 = Request["userPassword0"];

            if (string.IsNullOrEmpty(p0))
            {
                return(Json(JSHelper.JsonMessage("修改请输入原来的密码")));
            }

            var p1 = Request["userPassword1"];
            var p2 = Request["userPassword2"];

            if (string.IsNullOrEmpty(p1) || string.IsNullOrEmpty(p2))
            {
                return(Json(JSHelper.JsonMessage("新密码不能为空")));
            }

            if (!p1.Equals(p2))
            {
                return(Json(JSHelper.JsonMessage("两次输入的新密码不一致")));
            }

            var db   = new BaseRepository();
            var user = Account.currentUser;

            if (user == null)
            {
                return(Json(JSHelper.JsonMessage("网页已经过期,请重新登录")));
            }

            if (user.userPassword != p0)
            {
                return(Json(JSHelper.JsonMessage("原密码不正确")));
            }

            var u = db.GetEntitie <tbUser>(p => p.ID == user.ID);

            u.userPassword = p1;
            var result = db.Update <tbUser>(u);

            if (!string.IsNullOrEmpty(result))
            {
                return(Json(JSHelper.JsonMessage(result)));
            }

            return(Json(JSHelper.JsonMessage("操作成功", true)));
        }
예제 #9
0
        public ActionResult Index(FormCollection fn)
        {
            LogonModel logon = new LogonModel();

            UpdateModel <LogonModel>(logon);
            if (!ModelState.IsValid)
            {
                Json(JSHelper.JsonMessage("非法登录", false));
            }

            logon.logIP = Request.UserHostAddress.ToString();

            var result = Account.Logon(logon);

            if (!string.IsNullOrEmpty(result))
            {
                return(Json(JSHelper.JsonMessage(result)));
            }

            return(Json(JSHelper.JsonMessage("登录成功,请稍候……", true)));
        }