public static void AddOnLine(UserInfo usr) { if (_users.Count(u => u.Id == usr.Id) <= 0) { var usrs = _users; usrs.Add(usr); _users = usrs; } }
public static UserInfo Regester(UserInfo usr) { using (ChatDbContext db = new ChatDbContext()) { var ur = db.UserInfos.Add(usr); db.SaveChanges(); return ur; } }
public ActionResult Regester(UserInfo usr) { try { if (!string.IsNullOrEmpty(usr.Name) && !string.IsNullOrEmpty(usr.Password)) { var ur = _service.Regester(usr); _service.Login(ur.Name, ur.Password); HttpCookie cookie = new HttpCookie("DAKER_USR_ID", ur.Id.ToString()); cookie.Expires = DateTime.Now.AddMinutes(30); Response.Cookies.Add(cookie); Response.Redirect("../Home/index"); } return Content("用户名和密码不能为空."); } catch (Exception ex) { return Content(ex.Message); } }