public UserDTO RegisterNewUser(UserDTO user, string password) { // Validate username and password InputValidation.ValidatePassword(password); UserDTO ValidatedUser; try { Model.UserDTO NewUser = user.Translate(password); ValidatedUser = new UserDTO(Manager.RegisterUser(NewUser)); } catch (Exceptions.ValidationException e) { // Throw validation exceptions through throw e; } catch (Exception) { // Catch generic errors as a database error and throw database error throw new Exceptions.DatabaseException("Failed to connect to database."); } return(ValidatedUser); }
/// <summary> /// Keep track of information that may be displayed to the user or used for front end processes /// </summary> /// <param name="username"></param> /// <param name="email"></param> /// <param name="userLevel"></param> public UserDTO(Model.UserDTO user) { this.UID = user.UID; this.isValid = true; this.Username = user.UserName; this.Email = user.UserEmail; this.UserLevel = user.UserLevel; }