public bool Update(User user) { if (user == null) throw new ArgumentNullException("user"); var query = new DapperQuery(ConnectionString) { Sql = @"Update dbo.[User] set [Hash] = @Hash, [Salt] = @Salt, [hintquestion] = @HintQuestion, [hintanswer] = @HintAnswer WHERE Id = @Id", Parameters = new { Id = user.Id, Salt = user.Salt, Hash = user.Hash, HintQuestion = user.HintQuestion, HintAnswer = user.HintAnswer } }; try { QueryExecutor.Execute(query); return true; } catch (Exception) { return false; } }
public bool Create(User user) { if (user == null) throw new ArgumentNullException("user"); var query = new DapperQuery(ConnectionString) { Sql = @"Insert into dbo.[User]([name], [Hash], [Salt], [hintquestion], [hintanswer]) Values(@Name, @Hash, @Salt, @HintQuestion, @HintAnswer)", Parameters = new { Name = user.Name, Hash = user.Hash, Salt = user.Salt, HintQuestion = user.HintQuestion, HintAnswer = user.HintAnswer } }; try { QueryExecutor.Execute(query); return true; } catch (Exception) { return false; } }
public bool Create(User user) { if (user == null) throw new ArgumentNullException("user"); user.Id = _maxId++; if (_users.Any(x => x.Name == user.Name)) return false; _users.Add(user); return true; }
public bool Update(User user) { if (user == null) throw new ArgumentNullException("user"); var repoUser = _repository.GetByUserName(user.Name); if (repoUser == null) return false; if (repoUser.HintAnswer.ToLower() != user.HintAnswer.ToLower()) return false; user = (User)_hasher.Hash(user); user.Id = repoUser.Id; return _repository.Update(user); }
public bool Update(User user) { if (user == null) throw new ArgumentNullException("user"); var tobeUpdated = GetByUserName(user.Name); tobeUpdated.HintAnswer = user.HintAnswer; tobeUpdated.HintQuestion = user.HintQuestion; tobeUpdated.Password = ""; tobeUpdated.Hash = user.Hash; tobeUpdated.Salt = user.Salt; return true; }
public bool Create(User user) { if (user == null) throw new ArgumentNullException("user"); user = (User)_hasher.Hash(user); return _repository.Create(user); }