public JsonResult GenerateBill(BillRequest billRequest)
        {
            var  user = HttpContext.User;
            var  id   = Convert.ToInt32(user.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
            bool isBillingInEnglish;
            var  generatedBill = _billRepo.GenerateBill(billRequest, id, out isBillingInEnglish);
            //RenderBill(billHeader);

            var details = generatedBill.BillDetails.Select(d => new
            {
                BillDetailType = Convert.ToInt32(d.BillDetailType),
                d.FixedAmount,
                d.UnitRate,
                d.Quantity,
                d.Subtotal,
                d.Description,
                d.TaxesAmount
            }).ToList();
            string     basePath    = _hostingEnvironment.ContentRootPath;
            string     fullPath    = basePath + @"/Reports/Bill.rdlc";
            FileStream inputStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
            ReportDataSourceCollection dataSources = new ReportDataSourceCollection();

            dataSources.Add(new ReportDataSource {
                Name = "BillDataSet", Value = details
            });

            Syncfusion.ReportWriter.ReportWriter writer = new Syncfusion.ReportWriter.ReportWriter(inputStream, dataSources);
            //writer.DataSources = dataSources;
            //Setting up the parameters
            List <ReportParameter> parameters = new List <ReportParameter>();
            //IsEnglish
            ReportParameter isEnglishParam = new ReportParameter();

            isEnglishParam.Name   = "IsEnglish";
            isEnglishParam.Values = new List <string>()
            {
                isBillingInEnglish ? "1" : "0"
            };
            //IsBilled
            ReportParameter isBilledParam = new ReportParameter();

            isBilledParam.Name   = "IsBilled";
            isBilledParam.Values = new List <string>()
            {
                "1"
            };
            //ClientName
            ReportParameter clientNameParam = new ReportParameter();

            clientNameParam.Name   = "ClientName";
            clientNameParam.Values = new List <string>()
            {
                generatedBill.BillName
            };
            //BillingPeriod

            string culture       = isBillingInEnglish ? "en" : "es";
            string billingPeriod = $"{CultureInfo.GetCultureInfoByIetfLanguageTag(culture).DateTimeFormat.GetMonthName(DateTime.UtcNow.AddHours(-6).Month)} - {generatedBill.BillYear}";

            ReportParameter billingPeriodParam = new ReportParameter();

            billingPeriodParam.Name   = "BillingPeriod";
            billingPeriodParam.Values = new List <string>()
            {
                billingPeriod
            };
            //Subtotal
            ReportParameter subTotalExpenseParam = new ReportParameter();

            subTotalExpenseParam.Name   = "Subtotal";
            subTotalExpenseParam.Values = new List <string>()
            {
                generatedBill.BillSubtotal.ToString()
            };
            //Discount
            ReportParameter discountParam = new ReportParameter();

            discountParam.Name   = "Discount";
            discountParam.Values = new List <string>()
            {
                generatedBill.BillDiscount.ToString()
            };
            //Taxes
            ReportParameter taxesParam = new ReportParameter();

            taxesParam.Name   = "Taxes";
            taxesParam.Values = new List <string>()
            {
                generatedBill.Taxes.ToString()
            };
            //TotalExpense
            ReportParameter totalParam = new ReportParameter();

            totalParam.Name   = "Total";
            totalParam.Values = new List <string>()
            {
                generatedBill.Total.ToString()
            };
            //TotalExpense
            ReportParameter billDateParam = new ReportParameter();

            billDateParam.Name   = "BillDate";
            billDateParam.Values = new List <string>()
            {
                generatedBill.BillDate.ToString()
            };
            parameters.Add(isEnglishParam);
            parameters.Add(isBilledParam);
            parameters.Add(clientNameParam);
            parameters.Add(billingPeriodParam);
            parameters.Add(subTotalExpenseParam);
            parameters.Add(discountParam);
            parameters.Add(taxesParam);
            parameters.Add(totalParam);
            parameters.Add(billDateParam);
            writer.SetParameters(parameters);

            writer.ReportProcessingMode = ProcessingMode.Local;
            MemoryStream memoryStream = new MemoryStream();

            writer.Save(memoryStream, WriterFormat.PDF);
            memoryStream.Position = 0;
            FileStreamResult fileStreamResult = new FileStreamResult(memoryStream, "application/pdf");

            fileStreamResult.FileDownloadName = $"FacturaCliente{generatedBill.BillName}deMes{generatedBill.BillMonth}YAño{generatedBill.BillYear}.pdf";
            return(Json(new { result = memoryStream.ConvertToBase64() }));
        }