public void CreateUser(UserRegisterDto user) { try { userSrv.CreateUser(user); } catch(UserDataException ex) { throw new FaultException<ServiceValidationError>(new ServiceValidationError(ex.Message)); } }
public void CreateUser(UserRegisterDto user) { if(!db.Users.Any(u=>u.Login==user.Login) && !db.Users.Any(u => u.Email == user.Email)) { var newUser = Mapper.Map<UserRegisterDto, User>(user); AuthorizationHelper.GenerateKey(user.Password, newUser); db.Users.Add(newUser); db.SaveChanges(); } else { throw new UserDataException("user with such data already exists"); } }