Example #1
0
        public IActionResult GetSeedndImg(int seedid)
        {
            if (_productRepository.GetSeed(seedid) == null)
            {
                return(StatusCode(500, "不存在"));
            }

            var        model = _productRepository.GetFile(seedid);
            FilesPrint fhelp = new FilesPrint();

            byte[] bt = fhelp.ReadFile(fhelp.readURL(model.FileUrl));
            if (bt == null)
            {
                return(StatusCode(500, "读取异常"));
            }
            return(Ok(new FileUpDownLoadToByteDto
            {
                FID = model.FID,
                FileClass = model.FileClass,
                FileName = model.FileName,

                SeedID = model.seed.SeedID,
                Bytes = bt
            }));
        }
Example #2
0
        public IActionResult getSeedImg(int seedid)
        {
            if (seedid < 0)
            {
                return(BadRequest());
            }
            var model = _productRepository.GetSeed(seedid);

            if (model == null)
            {
                return(StatusCode(500, "获取失败"));
            }
            //var list = new List<SeedDto>();
            SeedAndImgDto seedDto = new SeedAndImgDto
            {
                SellerID    = model.SellerID,
                Species     = model.Species,
                Brand       = model.Brand,
                Details     = model.Details,
                SeedClass   = model.SeedClass,
                Exhibitions = model.Exhibitions,
                MakertID    = model.MakertID,
                MakertName  = _productRepository.GetSeller(model.SellerID).MarkerName,
                Name        = model.Name,

                Price = model.Price,
            };
            var filemodel = _productRepository.GetFile(model.SeedID);
            FileUpDownLoadToByteDto filedto = new FileUpDownLoadToByteDto
            {
                FID       = filemodel.FID,
                FileClass = filemodel.FileClass,
                FileUrl   = filemodel.FileUrl,
                FileName  = filemodel.FileName,
                SeedID    = filemodel.seed.SeedID
            };

            try
            {
                string     Imgurl = _productRepository.GetFile(model.SeedID).FileUrl;
                FilesPrint fp     = new FilesPrint();

                filedto.Bytes             = fp.ReadFile(fp.readURL(Imgurl));
                seedDto.FileUpDownLoadDto = filedto;
            }
            catch (Exception)
            {
                filedto.Bytes = null;
                throw;
            }


            return(Ok(seedDto));
        }