Example #1
0
        public async Task <IActionResult> OnPostAdminEmailAsync(CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(Partial("_SendAdminEmailPartial", this));
            }

            //send the email
            var result = await _sendEmail.SendAdminEmailMessageAsync(EmailProperties, cancellationToken);

            if (result != HttpStatusCode.Accepted)
            {
                //failed to send an email due to the SendGrid service being down or rejecting the request
                TempData["Error"] = "An error occured while processing your request. Please try again later.";
                return(Partial("_SendAdminEmailPartial", this));
            }

            TempData["EmailSent"] = "Your email was sent successfully. We will contact you as soon as possible";
            return(Partial("_SendAdminEmailPartial", this));
        }