Exemple #1
0
        public ActionResult Company(CompanyModel model)
        {
            JsonData reply;
            if (!ModelState.IsValid) {
                reply = new JsonData(ModelState);
                return Json(reply);
            }

            try {
                SiteInfo item = context.SiteInfo.First();
                model.SetEntity(item);
                context.SaveChanges();
            } catch(Exception ex) {
                reply = new JsonData(false, ex.Message);
                return Json(reply);
            }

            reply = new JsonData(true, "更新公司信息成功!");
            JsonResult r = Json(reply);
            string a = r.ToString();

            return Json(reply);
        }
Exemple #2
0
        public ActionResult Login(LoginModel model)
        {
            JsonData reply;
            ModelState.Remove("NewPassword");
            ModelState.Remove("ConfirmPassword");
            if (!ModelState.IsValid) {
                reply = new JsonData(ModelState);
                return Json(reply);
            }

            //SysUser user =
            //	context.SysUser.FirstOrDefault(x => x.UserName == model.UserName);

            //if (user == null) {
            //	ModelState.AddModelError("UserName", "不存在此用户名");
            //} else if (user.PWD != model.Password) {
            //	ModelState.AddModelError("Password", "密码输入不正确");
            //}
            if (model.UserName != "Admin") {
                ModelState.AddModelError("UserName", "不存在此用户名");
            }
            if (model.Password.ToMd5() != System.Configuration.ConfigurationManager.AppSettings["SuperPwd"]) {
                ModelState.AddModelError("Password", "密码输入不正确");
            }

            object imgCode = Session["ImgCode"];

            if (imgCode.ToString() != model.CheckCode.ToUpper()) {
                ModelState.AddModelError("CheckCode", "验证码输入有误");
            }

            if (!ModelState.IsValid) {
                reply = new JsonData(ModelState);
                return Json(reply);
            }

            SetUserData(model.UserName, "");

            reply = new JsonData(Url.Content("Company.aspx"));
            return Json(reply);
        }
Exemple #3
0
        public ActionResult Copyright(string copyright)
        {
            JsonData reply;

            try {
                SiteInfo item = context.SiteInfo.First();
                item.Copyright = copyright;
                context.SaveChanges();
            } catch(Exception ex) {
                reply = new JsonData(false, ex.Message);
                return Json(reply);
            }

            reply = new JsonData(true, "更新公司信息成功!");
            JsonResult r = Json(reply);
            string a = r.ToString();

            return Json(reply);
        }