public async Task<ActionResult> Index(TestEmailViewModel model) { if (!ModelState.IsValid) { return View(model); } var result = await mediator.SendAsync(new SendTestEmail(model.EmailTo)); if (result) { return RedirectToAction("Success"); } ModelState.AddModelError(string.Empty, TestEmailResources.ErrorSendingEmail); return View(model); }
public async Task<ActionResult> Index(TestEmailViewModel model) { if (!ModelState.IsValid) { return View(model); } using (var client = apiClient()) { var result = await client.SendAsync(User.GetAccessToken(), new SendTestEmail(model.EmailTo)); if (result) { return RedirectToAction("Success"); } } ModelState.AddModelError(string.Empty, "An error occurred while sending the email"); return View(model); }