private ApplicationValidationException CreateAndLogValidationException(Exception exception) { var applicationValidationException = new ApplicationValidationException(exception); //LOG return(applicationValidationException); }
protected void AddModelStateErrors(ApplicationValidationException exception) { if (exception == null) { return; } exception.Errors.ToList().ForEach(e => ModelState.AddModelError(e.PropertyName, e.ErrorMessage)); }
private void CheckCreateOrUpdateArguments(User user) { var otherWithUserName = _getUserByUsernameQuery.Execute(user.UserName); var otherWithEmail = _getUserByEmailQuery.Execute(user.EmailAddress); if (otherWithEmail != null || otherWithUserName != null) { var ex = new ApplicationValidationException(); if(otherWithUserName != null) { ex.AddError("UserName", "The user name selected is not available."); } if(otherWithEmail != null) { ex.AddError("EmailAddress", "The email address selected is not available."); } throw ex; } }