示例#1
0
        //
        // GET: /Member/Content/
        public ActionResult Index(int id)
        {
            #region 网站设置
            CustomCon custom  = (CustomCon)ConfigurationManager.GetSection("customCon");
            WebInfo   webInfo = custom.WebInfo;
            ViewBag.WebInfo = webInfo;
            #endregion
            Blog blog = blogManager.Find(id);
            if (blog == null)
            {
                return(View("Prompt", new Prompt()
                {
                    Title = "错误", Message = "该文章不存在!"
                }));
            }
            if (!blog.Publish)
            {
                return(View("Prompt", new Prompt()
                {
                    Title = "错误", Message = "该文章未发布!"
                }));
            }
            blog.Volume = blog.Volume + 1;
            blogManager.Update(blog);



            return(View(blog));
        }
示例#2
0
        public ActionResult Login(LoginModel_Me loginViewModel)
        {
            #region 网站设置
            CustomCon custom  = (CustomCon)ConfigurationManager.GetSection("customCon");
            WebInfo   webInfo = custom.WebInfo;
            ViewBag.WebInfo = webInfo;
            #endregion
            if (ModelState.IsValid)
            {
                string _password = Security.SHA256(loginViewModel.Password);
                var    _response = userManager.Login(loginViewModel.Username, _password);

                if (_response.Code == 1)
                {
                    User user = (User)_response.Data;
                    CurrUser.Serialize(user.ID, user.Username);

                    return(RedirectToAction("Index", "Home", new { Areas = "Member" }));
                }
                else if (_response.Code == 2)
                {
                    ModelState.AddModelError("Accounts", _response.Message);
                }
                else if (_response.Code == 3)
                {
                    ModelState.AddModelError("Password", _response.Message);
                }
                else
                {
                    ModelState.AddModelError("", _response.Message);
                }
            }
            return(View(loginViewModel));
        }
示例#3
0
        // [Import]
        //private IRoleManager roleManager ;
        //

        #region 登录
        public ActionResult Login()
        {
            #region 网站设置
            CustomCon custom  = (CustomCon)ConfigurationManager.GetSection("customCon");
            WebInfo   webInfo = custom.WebInfo;
            ViewBag.WebInfo = webInfo;
            #endregion
            return(View());
        }
示例#4
0
        public ActionResult Register(RegisterViewModel register)
        {
            #region 网站设置
            CustomCon custom  = (CustomCon)ConfigurationManager.GetSection("customCon");
            WebInfo   webInfo = custom.WebInfo;
            ViewBag.WebInfo = webInfo;
            #endregion

            if (userManager.HasUserName(register.UserName))
            {
                ModelState.AddModelError("UserName", "用户名已存在");
            }
            if (userManager.HasEmail(register.Email))
            {
                ModelState.AddModelError("Email", "Email已存在");
            }
            if (ModelState.IsValid)
            {
                User user = new User();
                if (TryUpdateModel(user))
                {
                    user.Password = Security.SHA256(register.Password);
                    user.RegTime  = DateTime.Now;
                    user.RoleID   = 1;
                    Response response = userManager.Add(user);
                    if (response.Code == 1)
                    {
                        user = response.Data;
                        CurrUser.Serialize(user.ID, user.Username);
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ViewBag.er = "注册失败:" + response.Message;
                    }
                }
            }
            ViewBag.er = "注册失败";
            return(View(register));
        }
示例#5
0
 private void ConnectionClose()
 {
     CustomCon.Close();
     TeamCon.Close();
 }