public async Task <ForgotUsernameResultModel> ForgotUsername([FromBody] ForgotInformationModel forgotInformationModel) { try { var forgotUsernameResultModel = new ForgotUsernameResultModel(); if (forgotInformationModel.emailAddress == null || forgotInformationModel.dateOfBirth == null) { forgotUsernameResultModel.Success = false; forgotUsernameResultModel.ErrorMessage = ErrorMessage.Null.ToString(); return(forgotUsernameResultModel); } var forgotUsernameResult = await _loginManager.ForgotUsername(forgotInformationModel.emailAddress, DateTimeOffset.Parse(forgotInformationModel.dateOfBirth)); forgotUsernameResultModel.Success = forgotUsernameResult.WasSuccessful; if (forgotUsernameResultModel.Success) { forgotUsernameResultModel.Username = forgotUsernameResult.SuccessValue; } else { forgotUsernameResultModel.ErrorMessage = forgotUsernameResult.ErrorMessage.ToString(); } return(forgotUsernameResultModel); } catch (SqlCustomException) { var forgotUsernameResultModel = new ForgotUsernameResultModel(); forgotUsernameResultModel.Success = false; forgotUsernameResultModel.ErrorMessage = "Could not verify the information given. Try again."; return(forgotUsernameResultModel); } catch (NullReferenceException) { var forgotUsernameResultModel = new ForgotUsernameResultModel(); forgotUsernameResultModel.Success = false; forgotUsernameResultModel.ErrorMessage = "A null was returned when checking the inputs."; return(forgotUsernameResultModel); } }