public static string CreateInvitationMessageWithInvitationCode(TripInvitationViewModel viewModel) { string message = $"\n\n{viewModel.TravelerLoggedIn.FirstName} has invited you to go on an adventure! \n Follow the link to register an account and join" + $" {viewModel.TravelerLoggedIn.FirstName} in the fun. But before you do, you'll need to enter a super secret adventure code.\n" + $"Once registered, look for the not so secret join adventure button and enter the following two part code: {viewModel.TravelerLoggedIn.UserName}, {viewModel.Trip.Name}.\n" + $"Happy Travels!\n" + "https://localhost:44324/Identity/Account/Register"; return(message); }
public IActionResult SendInvitations([FromForm] TripInvitationViewModel modelFromForm) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); modelFromForm.TravelerLoggedIn = _repo.Traveler.GetTravelerByUserId(userId); modelFromForm.Message.SenderAddress = modelFromForm.TravelerLoggedIn.Email; modelFromForm.Trip = _repo.Trip.GetTripById(modelFromForm.Trip.TripId); List <string> recipients = modelFromForm.Message.RecipientAddress.Split(", ").ToList(); string messageText = modelFromForm.Message.MessageBody + EmailInvitationMessageGenerator.CreateInvitationMessageWithInvitationCode(modelFromForm); MimeMessage email = EmailInvitation.CreateEmail(modelFromForm.Message.SenderAddress, recipients, messageText); modelFromForm.SentSuccessfully = EmailInvitation.SendEmailInvitation(email, API_Keys.EmailAddress, API_Keys.EmailPassword); if (modelFromForm.SentSuccessfully == true) { modelFromForm.Message = null; } return(PartialView("_TripInvitationPartial", modelFromForm)); }