public User InsertUser(User user) { var resultValidator = new UserValidator().Validate(user); if (!resultValidator.IsValid) { _helper.ValidatorHandler(resultValidator); } user.Password = _authenticationService.GetHash(user.Password); var userDTO = UserMapper.ConvertUserToDTO(user); if (_userContext.Insert(userDTO) == 1) { return(UserMapper.ConvertDTOToUser(_userContext.SelectAll().Where(w => w.Username == userDTO.Username).FirstOrDefault())); } return(null); }