public UserViewModel CreateUser(UserCreateUpdateModel model) { // validation var results = _userValidator.Validate(model).ToArray(); if (results.Length > 0) { throw new ValidationApiException(results); } if (_repo.GetUsers().Any(user => user.Email == model.Email)) { throw new DuplicateUserApiException("Email address already in use"); } User entity = _userMapper.EntityMapper(model); entity = _repo.CreateUser(entity); return(_userMapper.ViewMapper(entity)); }