public VerificationResult BeginVerification(ulong discordID, string uID) { try { if (IsDiscordUserVerifiedStudent(discordID)) { // assign the verified role again just in case it got deleted // roleAssignmentService.AssignVerifiedRoleToDiscordUser(discordID); string errorMessage = $"user is already verified with uID {uID}."; errorMessage += " if you to reset your verification (e.g. if you used the wrong uID or accidentally lost"; errorMessage += " the verified role), use the `$reset` command and then `$verify <uID>` again."; return(VerificationResult.FromError(errorMessage)); } VerificationResult validateInputsResult = ValidateBeginVerificationInputs(discordID, uID); if (!validateInputsResult.IsSuccess) { return(validateInputsResult); } string verificationCode = GenerateSixDigitVerificationCode(); Student student = new Student(discordID, uID, verificationCode, false); studentRepository.AddOrUpdateStudent(student); emailService.SendEmail(uID, verificationCode); string beginVerificationSuccessMessage = $"okay, i sent an email to your umail address ({uID}@umail.utah.edu)."; beginVerificationSuccessMessage += "\n**once you've received your code, DM it to me** (just reply to this message)."; beginVerificationSuccessMessage += " DON'T send your code in the get-verified channel."; return(VerificationResult.FromSuccess(beginVerificationSuccessMessage)); } catch (Exception e) { return(VerificationResult.FromError(e.Message)); } }
public int Post([FromBody] Student student) { _log.Info("Insert a new student: " + student.FirstName + " " + student.LastName); return(studentRepo.AddOrUpdateStudent(student)); }