public async Task <IActionResult> ConfirmOrder() { var response = await _orderRepository.ConfirmOrderAsync(this.User.Identity.Name); if (response != null) { try { PdfGenerator generator = new PdfGenerator(); var pdf = generator.CreatePdf(response, User.Identity.Name); _mailHelper.SendMailWithPDF(User.Identity.Name, "Order Confirmation", "You can find your order's details in the attachment.", pdf); return(View()); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); } } return(this.RedirectToAction("Index")); }