public async Task <IActionResult> GetPDFAsync([FromRoute] int Id)
        {
            try
            {
                RO_Garment model = await Facade.ReadByIdAsync(Id);

                RO_GarmentViewModel viewModel = Mapper.Map <RO_GarmentViewModel>(model);

                int timeoffsset = Convert.ToInt32(Request.Headers["x-timezone-offset"]);
                ROGarmentPdfTemplate PdfTemplate = new ROGarmentPdfTemplate();
                MemoryStream         stream      = PdfTemplate.GeneratePdfTemplate(viewModel, timeoffsset);

                return(new FileStreamResult(stream, "application/pdf")
                {
                    FileDownloadName = "RO Penjualan Umum " + viewModel.CostCalculationGarment.RO_Number + ".pdf"
                });
            }
            catch (System.Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public async Task <IActionResult> GetPDF([FromRoute] int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var        indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");
                int        timeoffsset    = Convert.ToInt32(Request.Headers["x-timezone-offset"]);
                RO_Garment model          = await Facade.ReadByIdAsync(Id);

                RO_GarmentViewModel viewModel = Mapper.Map <RO_GarmentViewModel>(model);

                if (model == null)
                {
                    Dictionary <string, object> Result =
                        new ResultFormatter(ApiVersion, Common.NOT_FOUND_STATUS_CODE, Common.NOT_FOUND_MESSAGE)
                        .Fail();
                    return(NotFound(Result));
                }
                else
                {
                    Service.Token = Request.Headers["Authorization"].First().Replace("Bearer ", "");

                    var productIds   = viewModel.CostCalculationGarment.CostCalculationGarment_Materials.Select(m => m.Product.Id).Distinct().ToList();
                    var productDicts = await costCalculationFacade.GetProductNames(productIds);

                    foreach (var material in viewModel.CostCalculationGarment.CostCalculationGarment_Materials)
                    {
                        material.Product.Name = productDicts.GetValueOrDefault(material.Product.Id);
                    }

                    ROGarmentPdfTemplate PdfTemplate = new ROGarmentPdfTemplate();
                    MemoryStream         stream      = PdfTemplate.GeneratePdfTemplate(viewModel, timeoffsset);

                    return(new FileStreamResult(stream, "application/pdf")
                    {
                        FileDownloadName = "RO Garment " + viewModel.Code + ".pdf"
                    });
                }
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, Common.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(Common.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public async Task <IActionResult> GetPDF([FromRoute] int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var        indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");
                int        timeoffsset    = Convert.ToInt32(Request.Headers["x-timezone-offset"]);
                RO_Garment model          = await Facade.ReadByIdAsync(Id);

                RO_GarmentViewModel viewModel = Mapper.Map <RO_GarmentViewModel>(model);

                if (model == null)
                {
                    Dictionary <string, object> Result =
                        new ResultFormatter(ApiVersion, Common.NOT_FOUND_STATUS_CODE, Common.NOT_FOUND_MESSAGE)
                        .Fail();
                    return(NotFound(Result));
                }
                else
                {
                    ROGarmentPdfTemplate PdfTemplate = new ROGarmentPdfTemplate();
                    MemoryStream         stream      = PdfTemplate.GeneratePdfTemplate(viewModel, timeoffsset);

                    return(new FileStreamResult(stream, "application/pdf")
                    {
                        FileDownloadName = "RO Garment " + viewModel.Code + ".pdf"
                    });
                }
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, Common.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(Common.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public IActionResult GetPDF([FromRoute] int Id)
        {
            try
            {
                var model     = Service.ReadModelById(Id).Result;
                var viewModel = Service.MapToViewModel(model);

                ROGarmentPdfTemplate PdfTemplate = new ROGarmentPdfTemplate();
                MemoryStream         stream      = PdfTemplate.GeneratePdfTemplate(viewModel);

                return(new FileStreamResult(stream, "application/pdf")
                {
                    FileDownloadName = "RO Penjualan Umum " + viewModel.CostCalculationGarment.RO + ".pdf"
                });
            }
            catch (System.Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }