示例#1
0
        public async Task <IActionResult> CartDownloadAsPDfAsync()
        {
            CartViewModel model = new CartViewModel
            {
                Name    = "Pro-forma Invoice",
                Account = (await _context.AccountUsers
                           .Include(x => x.Account)
                           .ThenInclude(x => x.Address)
                           .FirstOrDefaultAsync(x => x.UserId == User.FindFirst(ClaimTypes.NameIdentifier).Value&& x.Active))
                          .Account,
                CartItems = new GetCart(_context, _discounts).Do(GetCartUserMark()).ToList()
            };

            var result = await _viewRenderService.RenderToStringAsync("/Views/Cart/Default.cshtml", model);

            var file = await _pdfService.GetCartAsPDF(result);

            //return File(file.FileBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", file.FileName);
            return(File(file.FileBytes, "application/pdf"));
        }