示例#1
0
        public CategoryDetail Get(int id)
        {
            CategoryDetailRepository categoryDetailRepository;
            ProductBO      productBO;
            CategoryDetail categoryDetail;

            try
            {
                categoryDetailRepository = new CategoryDetailRepository(_loggerFactory, _config);
                productBO = new ProductBO(_loggerFactory, _config);

                categoryDetail          = categoryDetailRepository.Get(id);
                categoryDetail.Products = productBO.Get(categoryDetailID: categoryDetail.ID);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(categoryDetail);
        }
        public ProductImage Update(ProductImage image)
        {
            ProductBO  productBO;
            BlobFileBO blobFileBO;
            Product    product;

            try
            {
                productBO  = new ProductBO(_loggerFactory, _config);
                blobFileBO = new BlobFileBO(_loggerFactory, _config);

                if (string.IsNullOrEmpty(image.BlobFile?.ID))
                {
                    throw new Exception("ID vazio, avalie a utilização do POST");
                }
                else
                {
                    product = productBO.Get(image.ProductID);

                    if (product != null)
                    {
                        image.BlobFile = blobFileBO.Update(image.BlobFile);

                        product.ImageID = image.BlobFile.ID;
                        productBO.Update(product);
                    }
                    else
                    {
                        throw new Exception("Produto não encontrado");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(image);
        }