public object RegisterUser([FromBody] UserInfo user) { if (string.IsNullOrEmpty(user.Username) || string.IsNullOrEmpty(user.Email) || string.IsNullOrEmpty(user.Password)) { return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, $@"Username, Email, and Password all must be provided, and not null/empty." )); } if (!FieldChecking.IsWellformedEmailAddress(user.Email, Strings.Regex.email)) { return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, $@"Malformed email address '{user.Email}'." )); } if (!FieldChecking.IsValidUsername(user.Username, Strings.Regex.username)) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $@"Invalid username '{user.Username}'.")); } if (DbInterface.AccountExists(user.Username)) { return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, $@"Account already exists with username '{user.Username}'." )); } else { if (DbInterface.EmailInUse(user.Email)) { return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, $@"Account already with email '{user.Email}'." )); } else { DbInterface.CreateAccount(null, user.Username, user.Password.ToUpper().Trim(), user.Email); return(new { Username = user.Username, Email = user.Email, }); } } }