public IsLoginModel(bool isLogin, User user) { if(user!=null){ IsLogin = isLogin; UserId = isLogin ? user.ID : 0; UserName = isLogin ? user.UserName : ""; }else { IsLogin = false; } }
public User CreateUser(int groupid,string username, string password, string email, bool isEffect) { if (DbProvider.D<User>().Count(x => x.UserName == username) > 0) throw new UserCreateException(UserCreateException.DuplicateUserName); //if (DbProvider.D<User>().Count(x => x.Email == email) > 0) throw new UserCreateException(UserCreateException.DuplicateEmail); if (string.IsNullOrWhiteSpace(password)) throw new ArgumentNullException("password","密码不能为空. "); //var group=DbProvider.GetByID<UserGroup>(groupid) ?? DbProvider.GetByID<UserGroup>(3); User user = new User(); user.UserName = username; user.Password = password; user.AddTime = DateTime.Now; DbProvider.Add(user); DbProvider.SaveChanges(); return user; }
/// <summary> /// 保存登录信息 /// </summary> /// <param name="user"></param> private void SaveLoginInfo(User user) { user.LoginTime = DateTime.Now; user.LoginIP = Utility.GetIP(); _userService.UpdateUser(user); }
/// <summary> /// 保存登录信息 /// </summary> /// <param name="user"></param> private void SaveLoginInfo(User user) { }
/// <summary> /// 验证用户 /// </summary> /// <param name="nameOrEmailOrMobile"></param> /// <param name="password"></param> /// <param name="user"></param> /// <returns></returns> public bool ValidateUser(string nameOrEmailOrMobile, string password,out User user) { //Check.Argument.IsNotEmpty(nameOrEmailOrMobile,"nameOrEmailOrMobile"); //var member = DbProvider.D<User>().FirstOrDefault(x => x.UserName == nameOrEmailOrMobile || x.Email == nameOrEmailOrMobile || x.Mobile == nameOrEmailOrMobile); //if ( member == null || member.Password!=password.Hash() || member.IsBorrower) //{ // user = null; // return false; //} //user = member; //if (!member.IsEffect || member.IsDelete) //{ // return false; //} user = new User(); return true; }
public void UpdateUser(User user) { Check.Argument.IsNotNull(user, "user"); DbProvider.Update(user); DbProvider.SaveChanges(); }
public ActionResult PostEdit(User model) { User user = DbProvider.GetByID<User>(model.ID); if (user == null) return Error("用户不存在"); user.DeptId = model.DeptId; user.RealName = model.RealName; user.RoleId = model.RoleId; DbProvider.Update<User>(user); DbProvider.SaveChanges(); return Success("操作成功"); }
public ActionResult PostAdd(User user) { if (DbProvider.D<User>().Count(u => u.UserName.Trim() == user.UserName.Trim()) > 0) { return Error("用户已经存在"); } user.Role = DbProvider.D<Role>().FirstOrDefault(r => r.ID == user.RoleId); DbProvider.Add(user); return Success("操作成功"); }