コード例 #1
0
        public void Generate_Return_Success()
        {
            // var department = new UnitDepartmentId(1);
            var id = Guid.NewGuid();
            var garmentFinishingOut = new GarmentFinishingOut(Guid.NewGuid(), "finishingPrinting", new UnitDepartmentId(1), "unitToCode", "unitToCode", "finishingTo", DateTimeOffset.Now, "roNo", "Article", new UnitDepartmentId(1), "unitCode", "unitName", new GarmentComodityId(1), "comodityCode", "comodityName", false);

            GarmentFinishingOutDto dto = new GarmentFinishingOutDto(garmentFinishingOut)
            {
                CreatedBy = "CreatedBy",
            };
            var finishingOutItem = new GarmentFinishingOutItemDto(new GarmentFinishingOutItem(id, id, id, id, new ProductId(1), "productCode", "productName", "designColor", new SizeId(1), "sizeName", 1, new UomId(1), "uomUnit", "color", 1, 1, 1));

            finishingOutItem.Details = new List <GarmentFinishingOutDetailDto>()
            {
                new GarmentFinishingOutDetailDto(new GarmentFinishingOutDetail(id, id, new SizeId(1), "sizeName", 1, new UomId(1), "uomUnit"))
            };

            var items = new List <GarmentFinishingOutItemDto>()
            {
                finishingOutItem
            };

            dto.GetType().GetProperty("Items").SetValue(dto, items);


            var result = GarmentFinishingOutPDFTemplate.Generate(dto, "Buyer");

            Assert.NotNull(result);
        }
        public async Task <IActionResult> GetPdf(string id, string buyer)
        {
            Guid guid = Guid.Parse(id);

            VerifyUser();

            int clientTimeZoneOffset = int.Parse(Request.Headers["x-timezone-offset"].First());
            GarmentFinishingOutDto garmentFinishingOutDto = _garmentFinishingOutRepository.Find(o => o.Identity == guid).Select(finishOut => new GarmentFinishingOutDto(finishOut)
            {
                Items = _garmentFinishingOutItemRepository.Find(o => o.FinishingOutId == finishOut.Identity).Select(finishOutItem => new GarmentFinishingOutItemDto(finishOutItem)
                {
                    Details = _garmentFinishingOutDetailRepository.Find(o => o.FinishingOutItemId == finishOutItem.Identity).Select(finishOutDetail => new GarmentFinishingOutDetailDto(finishOutDetail)
                    {
                    }).ToList()
                }).ToList()
            }
                                                                                                                                ).FirstOrDefault();
            var stream = GarmentFinishingOutPDFTemplate.Generate(garmentFinishingOutDto, buyer);

            return(new FileStreamResult(stream, "application/pdf")
            {
                FileDownloadName = $"{garmentFinishingOutDto.FinishingOutNo}.pdf"
            });
        }