示例#1
0
 public User MapToUser(RegisterModel viewModel, User user)
 {
     user.UserId = Guid.NewGuid();
     user.CreateDate = DateTime.Now;
     user.Password = viewModel.Password;
     user.UserName = viewModel.UserName;
     return user;
 }
 public void Remove(User user)
 {
     using (var db = new DbDataContext())
     {
         var _user = db.Users.FirstOrDefault(x => x.UserId == user.UserId);
         if (_user != null)
         {
             db.Users.DeleteOnSubmit(_user);
             db.SubmitChanges();
         }
     }
 }
        public User Create(User user)
        {
            using (var db = new DbDataContext())
            {
                if (user != null)
                {
                    db.Users.InsertOnSubmit(user);
                    db.SubmitChanges();
                }
            }

            return user;
        }
 public void Update(User user)
 {
     using (var db = new DbDataContext())
     {
         var _user = db.Users.FirstOrDefault(x => x.UserId == user.UserId);
         if (user != null)
         {
             _user.Password = user.Password;
             _user.UserName = user.UserName;
             _user.GmailUser = user.GmailUser;
             _user.GmailPassword = user.GmailPassword;
             _user.CreateDate = user.CreateDate;
             db.SubmitChanges();
         }
     }
 }
示例#5
0
 partial void DeleteUser(User instance);
示例#6
0
 partial void UpdateUser(User instance);
示例#7
0
 partial void InsertUser(User instance);
 private bool ValidateUser(User user, LoginModel model)
 {
     return PasswordHash.ValidatePassword(model.Password, user.Password);
 }