public UserDTO Register(UserDTO user, string password) { var entity = GetUserByUserName(user.UserName, false); if (entity != null) throw new Exception("User is already registered"); var dbUser = user.ProjectedAs<User, int>(); dbUser.Password = PasswordHash.CreateHash(password); Repository.Add(dbUser); Repository.UnitOfWork.Commit(); return dbUser.ProjectedAs<UserDTO, int>(); }