public async Task <IActionResult> ConfirmOrder() { var createdOrder = await _orderRepository.ConfirmOrderAsync(User.Identity.Name); if (createdOrder != null) { try { EmailPDF generator = new EmailPDF(); var pdfByteArray = generator.PdfGenerate(createdOrder, User.Identity.Name); _mailHelper.SendEmailPlusAttachment(User.Identity.Name, "Order - Plants Store", "Thank you for choosing us.\n Please, check your email box! \n The purchase order follows attached", pdfByteArray); ViewBag.Message = "Thank you for choosing us!\n\n\nPlease check your email box."; } catch (Exception exception) { ModelState.AddModelError(string.Empty, exception.Message); } } return(RedirectToAction("Create")); }