public ActionResult Login() { var sr = new System.IO.StreamReader(Request.InputStream); var jss = new JavaScriptSerializer(); var obj = jss.Deserialize <Models.Userinfo>(sr.ReadToEnd());///前台传来的数据 Userinfo us = new Models.Userinfo(); us.UserName = obj.UserName; us.UserPassword = obj.UserPassword; var userinfo = db.Userinfo.Where(u => u.UserName == us.UserName && u.UserPassword == us.UserPassword).FirstOrDefault(); if (us.UserName == null || us.UserPassword == null || userinfo == null || !userinfo.State) { ModelState.AddModelError("", "登陆失败。"); return(View()); } else { ViewBag.user = userinfo.ID; Session["Role"] = userinfo.Role; //获取用户身份 Session["UserName"] = userinfo.UserName; //获取用户名 Session["UserId"] = userinfo.ID; //获取用户ID Session["UserIntegral"] = userinfo.Integral; //获取用户ID return(Json(new { success = true, ExecuteResult = "操作成功:" + userinfo.UserName + " 登陆成功。" }, JsonRequestBehavior.AllowGet)); } // return RedirectToAction("Index", "Home"); //return View(); }
/// <summary> /// 商城 启始页 /// </summary> /// <returns></returns> public ActionResult List() { Userinfo userinfo = new Models.Userinfo(); Session.Add("user", userinfo); return(View()); }
public ActionResult Register(FilaShop.User.User user) { Models.Userinfo u = new Models.Userinfo { Username = user.Username, Password = Comman.Md5.JiaMi(user.Password), Nickname = user.Nickname }; db.Userinfo.Add(u); db.SaveChanges(); if (user.returnurl != null && user.returnurl != "") { Session.Add("returnurl", user.returnurl); } return(RedirectToAction("Login")); }