コード例 #1
0
        public void Delete(int id)
        {
            CategoryDetailRepository categoryDetailRepository;
            BlobFileBO     blobFileBO;
            CategoryDetail categoryDetail;

            try
            {
                if (id == 0)
                {
                    throw new Exception("ID inválido");
                }
                else
                {
                    categoryDetailRepository = new CategoryDetailRepository(_loggerFactory, _config);
                    blobFileBO = new BlobFileBO(_loggerFactory, _config);

                    categoryDetail = Get(id);
                    if (categoryDetail != null)
                    {
                        if (!string.IsNullOrEmpty(categoryDetail.TitleIconID))
                        {
                            blobFileBO.Delete(categoryDetail.TitleIconID);
                        }
                        categoryDetailRepository.Delete(id);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public void Delete(long id)
        {
            ProductRepository productRepository;
            BlobFileBO        blobFileBO;
            Product           product;

            try
            {
                if (id == 0)
                {
                    throw new Exception("ID inválido");
                }
                else
                {
                    productRepository = new ProductRepository(_loggerFactory, _config);
                    blobFileBO        = new BlobFileBO(_loggerFactory, _config);

                    product = Get(id);
                    if (product != null)
                    {
                        if (!string.IsNullOrEmpty(product.ImageID))
                        {
                            blobFileBO.Delete(product.ImageID);
                        }
                        productRepository.Delete(id);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public Product Update(Product product)
        {
            ProductRepository       productRepository;
            ProductCategoryDetailBO productCategoryDetailBO;

            BlobFileBO blobFileBO;

            try
            {
                productRepository       = new ProductRepository(_loggerFactory, _config);
                productCategoryDetailBO = new ProductCategoryDetailBO(_loggerFactory, _config);
                blobFileBO = new BlobFileBO(_loggerFactory, _config);

                if (product.ID == 0)
                {
                    throw new Exception("ID diferente de 0, avalie a utilização do POST");
                }
                else
                {
                    productRepository.Update(product);
                    productCategoryDetailBO.Save(product.ID, product.ProductCategoryDetails);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(product);
        }
コード例 #4
0
        public BrandImage Update(BrandImage image)
        {
            BrandBO    brandBO;
            BlobFileBO blobFileBO;
            Brand      brand;

            try
            {
                brandBO    = new BrandBO(_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
                {
                    brand = brandBO.Get(image.BrandID);

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

                        switch (image.Destination)
                        {
                        case BrandImage.BrandImageDestination.Desktop:
                            brand.DesktopSpotlightImageID = image.BlobFile.ID;
                            break;

                        case BrandImage.BrandImageDestination.Mobile:
                            brand.MobileSpotlightImageID = image.BlobFile.ID;
                            break;

                        default:
                            break;
                        }

                        brandBO.Update(brand);
                    }
                    else
                    {
                        throw new Exception("Produto não encontrado");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(image);
        }
コード例 #5
0
        public CategoryImage Update(CategoryImage image)
        {
            CategoryBO categoryBO;
            BlobFileBO blobFileBO;
            Category   category;

            try
            {
                categoryBO = new CategoryBO(_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
                {
                    category = categoryBO.Get(image.CategoryID);

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

                        switch (image.Destination)
                        {
                        case CategoryImage.CategoryImageDestination.Desktop:
                            category.DesktopSpotlightImageID = image.BlobFile.ID;
                            break;

                        case CategoryImage.CategoryImageDestination.Mobile:
                            category.MobileSpotlightImageID = image.BlobFile.ID;
                            break;

                        default:
                            break;
                        }

                        categoryBO.Update(category);
                    }
                    else
                    {
                        throw new Exception("Produto não encontrado");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(image);
        }
コード例 #6
0
        public void Delete(string id)
        {
            BlobFileBO blobFileBO;

            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    throw new Exception("ID inválido");
                }
                else
                {
                    blobFileBO = new BlobFileBO(_loggerFactory, _config);

                    blobFileBO.Delete(id);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
        public CategoryDetailImage Update(CategoryDetailImage image)
        {
            CategoryDetailBO categoryDetailBO;
            BlobFileBO       blobFileBO;
            CategoryDetail   categoryDetail;

            try
            {
                categoryDetailBO = new CategoryDetailBO(_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
                {
                    categoryDetail = categoryDetailBO.Get(image.CategoryDetailID);

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

                        categoryDetail.TitleIconID = image.BlobFile.ID;
                        categoryDetailBO.Update(categoryDetail);
                    }
                    else
                    {
                        throw new Exception("Produto não encontrado");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(image);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        public void Delete(int id)
        {
            BrandRepository brandRepository;
            BlobFileBO      blobFileBO;
            Brand           brand;

            try
            {
                if (id == 0)
                {
                    throw new Exception("ID inválido");
                }
                else
                {
                    brandRepository = new BrandRepository(_loggerFactory, _config);
                    blobFileBO      = new BlobFileBO(_loggerFactory, _config);

                    brand = Get(id);
                    if (brand != null)
                    {
                        if (!string.IsNullOrEmpty(brand.DesktopSpotlightImageID))
                        {
                            blobFileBO.Delete(brand.DesktopSpotlightImageID);
                        }
                        if (!string.IsNullOrEmpty(brand.MobileSpotlightImageID))
                        {
                            blobFileBO.Delete(brand.MobileSpotlightImageID);
                        }

                        brandRepository.Delete(id);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #10
0
        public void Delete(int id)
        {
            CategoryRepository categoryRepository;
            BlobFileBO         blobFileBO;
            Category           category;

            try
            {
                if (id == 0)
                {
                    throw new Exception("ID inválido");
                }
                else
                {
                    categoryRepository = new CategoryRepository(_loggerFactory, _config);
                    blobFileBO         = new BlobFileBO(_loggerFactory, _config);

                    category = Get(id);
                    if (category != null)
                    {
                        if (!string.IsNullOrEmpty(category.DesktopSpotlightImageID))
                        {
                            blobFileBO.Delete(category.DesktopSpotlightImageID);
                        }
                        if (!string.IsNullOrEmpty(category.MobileSpotlightImageID))
                        {
                            blobFileBO.Delete(category.MobileSpotlightImageID);
                        }

                        categoryRepository.Delete(id);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #11
0
        public Product Get(long id)
        {
            ProductRepository       productRepository;
            ProductCategoryDetailBO productCategoryDetailBO;
            BlobFileBO blobFileBO;

            Product product;

            try
            {
                productRepository       = new ProductRepository(_loggerFactory, _config);
                productCategoryDetailBO = new ProductCategoryDetailBO(_loggerFactory, _config);
                blobFileBO = new BlobFileBO(_loggerFactory, _config);

                product = productRepository.Get(id);
                product.ProductCategoryDetails = productCategoryDetailBO.Get(product.ID);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(product);
        }