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(); } } }
partial void DeleteUser(User instance);
partial void UpdateUser(User instance);
partial void InsertUser(User instance);
private bool ValidateUser(User user, LoginModel model) { return PasswordHash.ValidatePassword(model.Password, user.Password); }