コード例 #1
0
        public async Task <ActionResult> ProductDelete(int productId)
        {
            var images = _productImage.FindAllAsync(x => x.ProductId == productId);

            foreach (var item in await images)
            {
                await _productImage.DeleteAsync(item);
            }

            var reviews = _review.FindAllAsync(x => x.ProductId == productId);

            foreach (var item in await reviews)
            {
                await _review.DeleteAsync(item);
            }

            var details = _orderDetail.FindAllAsync(x => x.ProductId == productId);

            foreach (var item in await details)
            {
                await _orderDetail.DeleteAsync(item);
            }

            await _product.DeleteByIdAsync(productId);

            return(Redirect("/trang-quan-tri/quan-ly-san-pham"));
        }
コード例 #2
0
        public async Task <ActionResult> PublisherDelete(int publisherId)
        {
            IEnumerable <ProductImage> images;
            IEnumerable <OrderDetail>  details;
            IEnumerable <Review>       reviews;

            var products = _product.FindAllAsync(x => x.PublisherId == publisherId);

            foreach (var product in await products)
            {
                images = await _productImage.FindAllAsync(x => x.ProductId == product.ProductId);

                foreach (var item in images)
                {
                    await _productImage.DeleteAsync(item);
                }

                reviews = await _review.FindAllAsync(x => x.ProductId == product.ProductId);

                foreach (var item in reviews)
                {
                    await _review.DeleteAsync(item);
                }

                details = await _orderDetail.FindAllAsync(x => x.ProductId == product.ProductId);

                foreach (var item in details)
                {
                    await _orderDetail.DeleteAsync(item);
                }

                await _product.DeleteAsync(product);
            }
            await _publisher.DeleteByIdAsync(publisherId);

            return(Redirect("/trang-quan-tri/quan-ly-nha-xuat-ban"));
        }
コード例 #3
0
        public async Task <ActionResult> CategoryDelete(int categoryId)
        {
            IEnumerable <ProductImage> images;
            IEnumerable <OrderDetail>  details;
            IEnumerable <Review>       reviews;

            var products = _product.FindAllAsync(x => x.CategoryId == categoryId);

            foreach (var product in await products)
            {
                images = await _productImage.FindAllAsync(x => x.ProductId == product.ProductId);

                foreach (var item in images)
                {
                    await _productImage.DeleteAsync(item);
                }

                reviews = await _review.FindAllAsync(x => x.ProductId == product.ProductId);

                foreach (var item in reviews)
                {
                    await _review.DeleteAsync(item);
                }

                details = await _orderDetail.FindAllAsync(x => x.ProductId == product.ProductId);

                foreach (var item in details)
                {
                    await _orderDetail.DeleteAsync(item);
                }

                await _product.DeleteAsync(product);
            }
            await _category.DeleteByIdAsync(categoryId);

            return(Redirect("/trang-quan-tri/quan-ly-danh-muc"));
        }