コード例 #1
0
        public async Task <IActionResult> ConvertToPdfAllSoldProducts(DateTime startDate, DateTime endDate)
        {
            object id;

            id = this.memoryCache.Get("SelectedProductId");

            object clientName;

            this.memoryCache.TryGetValue("ClientName", out clientName);

            var product = this.productService.GetProductById(Guid.Parse(id.ToString()));

            var allSold = new AllSoldProductsViewModel();

            allSold.SoldProducts  = this.productService.GetAllSoldProducts <SoldProductViewModel>(Guid.Parse(id.ToString()), startDate, endDate);
            allSold.TotalSoldQty  = allSold.SoldProducts.Sum(s => s.SoldQty);
            allSold.SoldSum       = allSold.TotalSoldQty * product.SinglePrice;
            allSold.ClientName    = clientName.ToString();
            allSold.InvoiceNumber = this.productService.GetProductById(Guid.Parse(id.ToString())).InvoiceNumber;
            var htmlData = await this.viewRenderService.RenderToStringAsync("~/Views/Products/AllSoldProductsForPdf.cshtml", allSold);

            var fileContents = this.htmlToPdfConverter.Convert("wwwroot/js/", htmlData);

            return(this.File(fileContents, "application/pdf;charset=utf-8"));
        }
コード例 #2
0
 public IActionResult AllSoldProducts(Guid id, DateTime startDate, DateTime endDate)
 {
     try
     {
         var allSold = new AllSoldProductsViewModel();
         allSold.SoldProducts = this.productService.GetAllSoldProducts <SoldProductViewModel>(id, startDate, endDate);
         this.memoryCache.Set("SelectedProductId", id.ToString());
         allSold.InvoiceNumber = this.productService.GetProductById(id).InvoiceNumber;
         return(this.View(allSold));
     }
     catch (Exception e)
     {
         return(this.View("~/Views/Products/Index"));
     }
 }