public async Task <IActionResult> testemail(TestEmailModel model) { if (ModelState.IsValid) { var result = await _emailService.SendEmailAsync(new EmailMessage { EmailAddress = model.Email, Subject = $"Test message from {WebSiteOptions.WebSiteTitle}", Body = $"This is a test message from {WebSiteOptions.WebSiteTitle}.{Environment.NewLine}{Environment.NewLine}{model.Message}" }); if (result.Success) { AlertMessageCollection.AddSuccessAlert($"Email sent to {model.Email}\n{result.Details}", "Email Sent!"); } else { AlertMessageCollection.AddDangerAlert(result.Details, "Email Failure"); } } return(View()); }
public void GetSingleAlert() { var message = "Something bad happened"; var title = "Error"; _alertMessageCollection.AddDangerAlert(message, title); foreach (var messageType in (AlertMessageTypes[])Enum.GetValues(typeof(AlertMessageTypes))) { if (messageType == AlertMessageTypes.Danger) { Assert.AreEqual(1, _alertMessageCollection.GetCount(messageType)); var messages = _alertMessageCollection.GetAlertMessages(messageType).ToList(); Assert.AreEqual(1, messages.Count); Assert.AreEqual(message, messages[0].Message); Assert.AreEqual(title, messages[0].Title); } else { Assert.AreEqual(0, _alertMessageCollection.GetCount(messageType)); Assert.IsEmpty(_alertMessageCollection.GetAlertMessages(messageType)); } } }