private static async Task SendMaskRequestDeniedEmail(EmailSettings emailSettings, MaskRequestModel maskRequestModel, string message = "") { var htmlMessageSB = new StringBuilder(await EmailUtils.GetEmailHTMLTemplate(EmailMessageType.MaskRequestDenied)); htmlMessageSB.Replace("{Message}", !string.IsNullOrEmpty(message) ? message : @"We’re sorry, we’re not able to list your request.<br />Your request does not meet the requirements.<br />Please, for more details visit https://midwesthelps.com/resources. <br />Thank you!"); await EmailUtils.SendEmailAsync(emailSettings, htmlMessageSB.ToString(), "We’re sorry, we’re not able to list your request", "Mask request denied", maskRequestModel.Recipient.Email); }
public async Task <IActionResult> Post([FromBody] Contact contact) { try { if (!ContactValid(contact)) { throw new ErrorModelException(ErrorCode.InvalidField); } contact.PartitionKey = partitionKey; contact.CreatedOn = DateTime.UtcNow; _dataContext.Contacts.Add(contact); await _dataContext.SaveChangesAsync(); await EmailUtils.SendEmailAsync(_emailSettings, EmailMessageType.Contact, "Thanks for contacting us!", "Thanks for contacting us!", contact.Email, contact.Name); return(Ok()); } catch (Exception ex) { this._logger.LogError(ex, "Error sending contact email"); return(BadRequest()); } }
public async Task <ActionResult <MaskRequestModel> > Post(MaskRequestModel maskRequestModel) { var toReturn = await MaskRequest.Create(_dataContext, maskRequestModel); _ = EmailUtils.SendEmailAsync(_emailSettings, EmailMessageType.MaskRequestSubmitted, "Your mask request is in review", "Request in review", maskRequestModel.Recipient.Email); return(toReturn); }
public static async Task <MaskDonationModel> CreateMaskDonation(DataContext dataContext, EmailSettings emailSettings, MaskDonationModel maskDonationModel) { var maskDonation = await MaskDonation.Create(dataContext, maskDonationModel); await SendDonationOnItsWayEmail(emailSettings, maskDonation); await EmailUtils.SendEmailAsync(emailSettings, EmailMessageType.MaskDonationSubmitted, "Your donation was submitted successfully", "Donation offer received", maskDonationModel.Donor.Email); return(maskDonation); }
private static async Task SendDonationOnItsWayEmail(EmailSettings emailSettings, MaskDonationModel maskDonationModel) { var recipient = maskDonationModel.Request.Recipient; var donor = maskDonationModel.Donor; var updateStatusLink = "midwesthelps.com/donationStatus"; var donorCompany = !string.IsNullOrEmpty(donor.Company) ? $"<br />{donor.Company}" : ""; var htmlMessageSB = new StringBuilder(await EmailUtils.GetEmailHTMLTemplate(EmailMessageType.DonationOnItsWay)); htmlMessageSB.Replace("{DonorName}", donor.Name) .Replace("{DonorEmail}", donor.Email) .Replace("{DonorPhone}", donor.Phone) .Replace("{DonorCompany}", donorCompany) .Replace("{MaskDetails}", getMaskDetailsForEmail(maskDonationModel.Donation)) .Replace("{Status}", EnumUtils.GetName(DonationStatus.Received)) .Replace("{Id}", maskDonationModel.Id.ToString()) .Replace("{ReceivedDonationLink}", updateStatusLink); await EmailUtils.SendEmailAsync(emailSettings, htmlMessageSB.ToString(), $"{maskDonationModel.Donor.Name} has a donation!", "You got a donation offer", recipient.Email); }
public async static Task <MaskRequestModel> ApproveMaskRequest(EmailSettings emailSettings, DataContext dataContext, Guid id) { var newMaskRequest = await MaskRequest.GetApproved(dataContext, id, false); if (newMaskRequest == null) { throw new ErrorModelException(ErrorCode.NotFound, "Request"); } await MaskRequest.UpdateOriginalId(dataContext, newMaskRequest.OriginalId, newMaskRequest.Id); newMaskRequest.Approved = true; await AddRequestedMasksToAggregate(dataContext, newMaskRequest); await dataContext.SaveChangesAsync(); var maskRequestModel = newMaskRequest.ToMaskRequestModel(); await EmailUtils.SendEmailAsync(emailSettings, EmailMessageType.MaskRequestApproved, "Your mask request is approved!", "Mask request approved", maskRequestModel.Recipient.Email); return(maskRequestModel); }