public UserViewModel Register(UserViewModel user, string password) { if (_unitOfWork.AuthRepository.EmailExists(user.Email)) { return(null); } StaticHelpers.CreatePasswordHash(password, out byte[] passwordHash, out byte[] passwordSalt); User model = _mapper.Map <User>(user); model.PasswordHash = passwordHash; model.PasswordSalt = passwordSalt; model = _unitOfWork.AuthRepository.Register(model); _unitOfWork.SaveChanges(); return(_mapper.Map <UserViewModel>(model)); }