public int UserAddByrole(mUser user, string rolename) { int userid = UserAdd(user); RoleAdduser(userid, RoleGet(rolename).Id); return(userid); }
public mUser UserUpdate(mUser muser) { User user = user_repo.Get(d => d.id == muser.Id); muser.ToDb(user); SubmitChanges(); return(new mUser(user)); }
public int UserAdd(mUser newuser) { newuser.Password = Encrypt.EncryptUserPassword(newuser.Password); User user = new User(); user_repo.Add(newuser.ToDb(user)); SubmitChanges(); return(user.id); }
public mUser Login(string name, string pwd) { pwd = Encrypt.EncryptUserPassword(pwd); User user = user_repo.Get(d => d.name == name && d.password == pwd); if (user == null) { return(null); } mUser muser = new mUser(user); return(muser); }
public static FormsAuthenticationTicket CreateTicket(mUser user, IList<mRole> roles, IList<mAuth> auths) { var userInfo = new UserIdentity { Id = user.Id.ToString(), Name = user.Name, Email = user.Id.ToString(), Roles = String.Join(",", roles), Auths = String.Join(",", auths) }; var ticket = new FormsAuthenticationTicket(1, user.Name, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout), false, userInfo.ToString()); return ticket; }
public ActionResult Register(RegisterModel model) { if (!ModelState.IsValid) return View(model); if (user_get.UserCheckNameExist(model.UserName)) { ModelState.AddModelError("", "用户名已存在。"); return View(model); } mUser user = new mUser { Name = model.UserName, Password = model.Password }; user_sub.UserAdd(user); //user_sub.UserAddByrole(user, "Guest"); var roles = user_get.RoleGetByuser(user.Id); var auths = user_get.AuthGetByuser(user.Id); authentication.SetAuthCookie(this.HttpContext, AuthenticationTicketBuilder.CreateTicket(user, roles, auths)); return RedirectToAction("Use", "Seat"); }
public JsonResult UseUpdate(int seatId, string defineJson, string cache, string userstore) { UserIdentity user = (UserIdentity)ViewBag.UserModel; mSeat seat = seat_get.SeatGet(seatId); try { if (seat.EditUserId != 0 && int.Parse(user.Id) != seat.EditUserId) throw new ConcurrentException(); mSeat upseat = new mSeat { Id = seatId, DefineJson = defineJson, Cache = cache }; seat_sub.SeatUpdateByuser(upseat, int.Parse(user.Id)); mUser upuser = new mUser { Id = int.Parse(user.Id), StoreData = userstore }; user_sub.UserUpdate(upuser); } catch (Exception ex) { return Json(new { result = false, msg = ex.Message }); } return Json(new { result = true }); }
public mUser UserUpdate(mUser muser) { User user = user_repo.Get(d => d.id == muser.Id); muser.ToDb(user); SubmitChanges(); return new mUser(user); }
public int UserAddByrole(mUser user, string rolename) { int userid = UserAdd(user); RoleAdduser(userid, RoleGet(rolename).Id); return userid; }
public int UserAdd(mUser newuser) { newuser.Password = Encrypt.EncryptUserPassword(newuser.Password); User user = new User(); user_repo.Add(newuser.ToDb(user)); SubmitChanges(); return user.id; }
public mUser Login(string name, string pwd) { pwd = Encrypt.EncryptUserPassword(pwd); User user = user_repo.Get(d => d.name == name && d.password == pwd); if (user == null) return null; mUser muser = new mUser(user); return muser; }