public async Task SetStatusAsync_SetHiveSectionStatus(int categoryId, bool categoryStatusBefor, bool categoryStatusAfter)
        {
            // arrange
            var dbProductCategory = new DbProductCategory();

            dbProductCategory.Id = categoryId;

            dbProductCategory.IsDeleted = categoryStatusBefor;

            Assert.Equal(categoryStatusBefor, dbProductCategory.IsDeleted);

            var dbProductCategores = new[] { dbProductCategory };

            var context = new Mock <IProductCatalogueContext>();

            context.Setup(s => s.Categories).ReturnsEntitySet(dbProductCategores);

            var userContext = new Mock <IUserContext>();

            userContext.Setup(s => s.UserId).Returns(1);

            var service = new ProductCategoryService(context.Object, userContext.Object);

            // act
            await service.SetStatusAsync(categoryId, categoryStatusAfter);

            // assert
            Assert.Equal(categoryStatusAfter, dbProductCategory.IsDeleted);
        }
        public async Task UpdateCategoryAsync_CategoryIdAndUpdateProductCategoryRequest_ProductCategoryInstance(
            [Frozen] Mock <IProductCatalogueContext> context,
            ProductCategoryService service,
            IFixture fixture)
        {
            // Arrange
            var categoryId = 1;

            var dbUpdateRequest = fixture.Create <UpdateProductCategoryRequest>();

            var dbSections = fixture.CreateMany <DbProductCategory>(1).ToList();

            dbSections[0].Id = categoryId;

            dbSections[0].Code = $"{dbUpdateRequest.Code} + 1";

            context.Setup(s => s.Categories).ReturnsEntitySet(dbSections);

            // Act
            var updateCategory = await service.UpdateCategoryAsync(categoryId, dbUpdateRequest);

            // Assert
            Assert.Equal(dbUpdateRequest.Name, updateCategory.Name);
            Assert.Equal(dbUpdateRequest.Code, updateCategory.Code);
        }
        public async Task GetCategoriesAsync_IntStartAndAmount_ListProductCategoryListItems(
            [Frozen] Mock <IProductCatalogueContext> context,
            ProductCategoryService service,
            IFixture fixture)
        {
            // arrange
            var dbCategories = fixture.CreateMany <DbProductCategory>(2).OrderBy(s => s.Id).ToList();

            var dbProducts = fixture.CreateMany <CatalogueProduct>(5).ToList();

            dbProducts[0].CategoryId = dbCategories[0].Id;
            dbProducts[1].CategoryId = dbCategories[0].Id;
            dbProducts[2].CategoryId = dbCategories[1].Id;
            dbProducts[3].CategoryId = dbCategories[1].Id;
            dbProducts[4].CategoryId = dbCategories[1].Id;

            int start = 0, amount = 2;

            context.Setup(s => s.Categories).ReturnsEntitySet(dbCategories);

            context.Setup(s => s.Products).ReturnsEntitySet(dbProducts);

            // act
            var productCategoryListItems = await service.GetCategoriesAsync(start, amount);

            // assert
            Assert.Equal(2, productCategoryListItems.Count);

            Assert.Collection(
                productCategoryListItems,
                item => Assert.Equal(2, productCategoryListItems[0].ProductCount),
                item => Assert.Equal(3, productCategoryListItems[1].ProductCount));
        }
示例#4
0
        public async Task <ActionResult> Products(int take = 1, int description = 300, int imageHeight = 50, int imageWidth = 50, int isDetailLink = 0)
        {
            // var productsTask = ProductService.GetProductsAsync(StoreId, take, true);
            var productsTask = ProductService.GetProductsByProductTypeAsync(StoreId, null, null, null, StoreConstants.ProductType, 1,
                                                                            take, true, "random", null);
            var productCategoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true);
            var storeTask             = StoreService.GetStoreAsync(StoreId);

            await Task.WhenAll(storeTask, productsTask, productCategoriesTask);

            var store             = storeTask.Result;
            var products          = productsTask.Result;
            var productCategories = productCategoriesTask.Result;

            var feed = ProductHelper.GetProductsRssFeed(store, products, productCategories, description, isDetailLink);

            ProductHelper.ImageWidth  = imageWidth;
            ProductHelper.ImageHeight = imageHeight;
            ProductHelper.StoreId     = StoreId;
            var comment = new StringBuilder();

            comment.AppendLine("Take=Number of rss item; Default value is 10  ");
            comment.AppendLine("Description=The length of description text.Default value is 300  ");
            return(new FeedResult(feed, comment));
        }
示例#5
0
        private string GetList(HttpContext context)
        {
            ProductCategoryEntity entity = new ProductCategoryEntity();

            entity.deleted  = false;
            entity.Category = context.Request["category"];
            entity.ParentId = context.Request["parentid"].ToNullable <int>();


            Pagination pagination = new Pagination();

            pagination.PageIndex = Convert.ToInt32(HttpContext.Current.Request["pageIndex"].ToInt(1));
            pagination.PageSize  = Convert.ToInt32(HttpContext.Current.Request["pageSize"].ToInt(3));
            pagination.IsPaging  = (bool)context.Request["isPaging"].To <bool>(false);

            ProductCategoryService       service = new ProductCategoryService();
            List <ProductCategoryEntity> list    = service.GetList(entity, pagination);

            var resultObj = new
            {
                page = pagination,
                data = list,
                code = 10000
            };

            //将对象序列化成为JSON格式
            return(Newtonsoft.Json.JsonConvert.SerializeObject(resultObj));
        }
示例#6
0
        public object UpdateProductCategoryByCategoryId()
        {
            var model = new ProductCategoryInfo();

            model.Id            = Convert.ToInt32(HttpContext.Current.Request.Params["CategoryId"]);
            model.Name          = HttpContext.Current.Request.Params["CategoryName"];
            model.Desc          = (string)HttpContext.Current.Request.Params["desc"];
            model.BigPicture    = HttpContext.Current.Request.Params["BigPicture"];
            model.SmallPicture  = HttpContext.Current.Request.Params["SmallPicture"];
            model.MediumPicture = HttpContext.Current.Request.Params["mediumpicture"];
            model.Content       = HttpContext.Current.Request.Params["desc"];
            var display = 0;

            if (int.TryParse(HttpContext.Current.Request.Form["DisplayOrder"], out display))
            {
                model.DisplayOrder = display;
            }
            else
            {
                model.DisplayOrder = display;
            }
            //model.ParentId = int.Parse(HttpContext.Current.Request.Form["parentSelect"]);
            IProductCategoryService productCategoryService = new ProductCategoryService();

            return(productCategoryService.Update(model));
        }
示例#7
0
        public ActionResult ViewSellProductQty(int nStoreID, int nStoreProductID)
        {
            GlobalSession.SessionIsAlive(Session, Response);
            _oStoreProduct         = new StoreProduct();
            _oStoreProduct.StoreID = nStoreID;

            if (nStoreProductID > 0)
            {
                _oStoreProduct = _oStoreProductService.Get(nStoreID, nStoreProductID, (int)Session[GlobalSession.UserID]);
            }
            ContractorService oContractorService = new ContractorService();
            List <Contractor> oContractors       = new List <Contractor>();

            oContractors = oContractorService.GetsByContractorType(EnumContractorType.Supplier, (int)Session[GlobalSession.UserID]);

            List <ProductCategory> oProductCategorys       = new List <ProductCategory>();
            ProductCategoryService oProductCategoryService = new ProductCategoryService();

            oProductCategorys = oProductCategoryService.Gets(1, (int)Session[GlobalSession.UserID]);

            List <Product> oProducts       = new List <Product>();
            ProductService oProductService = new ProductService();

            oProducts = oProductService.Gets(1, (int)Session[GlobalSession.UserID]);

            ViewBag.ProductTypes     = _oProductTypeService.Gets(1, (int)Session[GlobalSession.UserID]);
            ViewBag.Contractors      = oContractors;
            ViewBag.Products         = oProducts;
            ViewBag.ProductCategorys = oProductCategorys;

            return(View(_oStoreProduct));
        }
        public ActionResult Save(int?id, int?CategoryPSN, string CategoryPSNTitle, string CategoryPSN_0)
        {
            ViewBag.parenttypes = ListToSelect(ProductCategoryService.GetParentTypes().Select(o => new SelectListItem()
            {
                Value = o.CategorySN.ToString(), Text = o.Title
            }), emptyTitle: "请选择");
            var obj = new ProductCategory()
            {
                State = 1
            };
            SelectListItem category = null;

            if (id.HasValue)
            {
                obj      = ProductCategoryService.GetObj(id.Value);
                category = new SelectListItem {
                    Value = obj.CategoryPSN.ToString(), Text = obj.CategoryPSNTitle, Selected = true
                };
            }
            else if (CategoryPSN.HasValue)
            {
                category = new SelectListItem()
                {
                    Value = CategoryPSN.ToString(), Text = CategoryPSNTitle, Selected = true
                }
            }
            ;
            ViewBag.category      = category;
            ViewData["SelectPSN"] = CategoryPSN_0;
            return(View(obj.IsNullThrow()));
        }
        public async Task GetCategoryAsync_IdNotPresent_RequestedResourceNotFoundExceptionThrown()
        {
            var mockUserContext    = new Mock <IUserContext>();
            var mockProductContext = new Mock <IProductCatalogueContext>();
            List <CatalogueProduct> productList = new List <CatalogueProduct>()
            {
                new CatalogueProduct()
                {
                    Id = 1, CategoryId = 1
                },
                new CatalogueProduct()
                {
                    Id = 2, CategoryId = 2
                }
            };
            List <DbCategory> categoryList = new List <DbCategory>()
            {
                new DbCategory()
                {
                    Id = 1
                },
                new DbCategory()
                {
                    Id = 2
                }
            };

            mockProductContext.Setup(c => c.Products).ReturnsEntitySet(productList);
            mockProductContext.Setup(c => c.Categories).ReturnsEntitySet(categoryList);
            var service = new ProductCategoryService(mockProductContext.Object, mockUserContext.Object);

            Assert.ThrowsAsync <RequestedResourceNotFoundException>(() => service.GetCategoryAsync(0));
        }
        public ActionResult FindPageList()
        {
            int count = 0;
            var ls    = ProductCategoryService.FindPageList(Request.Params, out count);

            return(ToDataGrid(ls, ls.Count));
        }
        public ActionResult ParentCategory(bool showAll = false, string emptyTitle = "请选择")
        {
            var parenttypes = ProductCategoryService.GetParentCategorys(showAll).Select(o => new DropdownItem(o.CategorySN.ToString(), o.Title)).ToList();

            parenttypes.Insert(0, new DropdownItem("", Server.UrlDecode(emptyTitle), true));
            return(new JsonNetResult(parenttypes));
        }
        public ActionResult Save(string id)
        {
            ViewBag.customers = EnumToSelect(typeof(CustomerType), selectValue: 0);
            ViewBag.shops     = ListToSelect(WarehouseService.GetList().Select(o => new SelectListItem()
            {
                Value = o.StoreId, Text = o.Title
            }), emptyTitle: "全部", emptyValue: "-1");
            ViewBag.times = CommonRules.TimeLines;
            var parents = ProductCategoryService.GetParentTypes().Select(o => new DropdownItem()
            {
                Value = o.CategorySN.ToString(), Text = o.Title
            }).ToList();

            ViewBag.parenttypes = parents.ToJson();
            parents             = ProductBrandService.GetList().Select(o => new DropdownItem(o.BrandSN.ToString(), o.Title)).ToList();
            ViewBag.brands      = parents.ToJson();
            var obj = new PromotBlend();

            if (!id.IsNullOrEmpty())
            {
                obj = CommodityPromotionService.FindZuheById(id);
                if (obj.Timeliness == 1)
                {
                    ViewBag.times = new List <string>()
                    {
                        obj.StartAging1, obj.EndAging1, obj.StartAging2, obj.EndAging2, obj.StartAging3, obj.EndAging3
                    }
                }
                ;
            }
            return(View(obj));
        }
示例#13
0
        private async Task <String> GetProductCategoriesHtml(string designName, int imageWidth, int imageHeight)
        {
            string returnHtml;
            var    categoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType,
                                                                                              true);
            var pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, designName);

            ProductCategoryHelper.StoreSettings = GetStoreSettings();
            ProductCategoryHelper.ImageWidth    = imageWidth == 0
                                                   ? GetSettingValueInt("ProductCategoriesPartial_ImageWidth", 50)
                                                   : imageWidth;
            ProductCategoryHelper.ImageHeight = imageHeight == 0
                                                    ? GetSettingValueInt("ProductCategoriesPartial_ImageHeight", 50)
                                                    : imageHeight;

            await Task.WhenAll(categoriesTask, pageDesignTask);

            var categories = categoriesTask.Result;
            var pageDesign = pageDesignTask.Result;

            var pageOuput = ProductCategoryHelper.GetProductCategoriesPartial(categories, pageDesign);

            returnHtml = pageOuput.PageOutputText;

            return(returnHtml);
        }
        public ActionResult Delete(int CATEGORY_ID = 0)
        {
            if (Request.IsAjaxRequest())
            {
                if (ModelState.IsValid && CATEGORY_ID > 0)
                {
                    using (var service = new ProductCategoryService())
                    {
                        var deleteResult = service.DeleteProductCategory(CATEGORY_ID);

                        JsonResult result = Json(new
                        {
                            statusCode = deleteResult ? Constant.SUCCESSFUL : Constant.INTERNAL_SERVER_ERROR
                        }, JsonRequestBehavior.AllowGet);

                        return(result);
                    }
                }
                else
                {
                    var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
                }
            }

            return(new EmptyResult());
        }
示例#15
0
        public ActionResult Save(int?id, string supplierId)
        {
            ViewBag.companys = ListToSelect(WarehouseService.GetList().Select(o => new SelectListItem()
            {
                Value = o.StoreId, Text = o.Title, Selected = o.StoreId == CurrentUser.StoreId
            }), emptyTitle: "请选择");
            ViewBag.parenttypes = ListToSelect(ProductCategoryService.GetParentTypes().Select(o => new SelectListItem()
            {
                Value = o.Id.ToString(), Text = o.Title
            }), emptyTitle: "请选择");
            //ViewBag.suppliers = ListToSelect(SupplierService.GetList().Where(o => o.BusinessType == 1 && o.MasterState == 1).Select(o => new SelectListItem() { Value = o.Id, Text = o.Title, Selected = o.Id == supplierId }));
            var obj = new Logic.Entity.IndentOrder()
            {
                CreateUID = Sys.CurrentUser.UID, State = (short)OrderState.未提交
            };

            if (Sys.CurrentUser.IsStore)
            {
                obj.StoreId = Sys.CurrentUser.StoreId;
            }
            if (id.HasValue)
            {
                obj = OrderService.FindById(id);
            }
            return(View(obj.IsNullThrow()));
        }
示例#16
0
        // GET: Product

        public ActionResult Index(string cateKey, int page = 1)
        {
            int pageSize = 8;

            ViewData["pageSize"] = pageSize;
            ProductCategoryViewModel prctViewModel = new ProductCategoryViewModel();

            //lấy ra danh sách sản phẩm theo loại
            if (cateKey == "tat-ca")
            {
                prctViewModel.ListProductCategory = ProductCategoryService.LoadProductAll();
            }
            else
            {
                if (cateKey == "dong-ho-nam")
                {
                    prctViewModel.ListProductCategory = ProductCategoryService.LoadProductMen();
                }
                else
                {
                    prctViewModel.ListProductCategory = ProductCategoryService.LoadProductWomen();
                }
            }

            int totalRecord = prctViewModel.ListProductCategory.Count;

            prctViewModel.CateKey   = cateKey;
            prctViewModel.Index     = page;
            prctViewModel.TotalPage = (int)(Math.Ceiling(((double)totalRecord / pageSize)));

            return(View(prctViewModel));
        }
        public async Task GetCategoriesAsync_TwoElementsRequested_ReturnsCollectionWithTwoElements()
        {
            var mockUserContext    = new Mock <IUserContext>();
            var mockProductContext = new Mock <IProductCatalogueContext>();
            List <CatalogueProduct> productList = new List <CatalogueProduct>()
            {
                new CatalogueProduct()
                {
                    Id = 1, CategoryId = 1
                },
                new CatalogueProduct()
                {
                    Id = 2, CategoryId = 2
                }
            };
            List <DbCategory> categoryList = new List <DbCategory>()
            {
                new DbCategory()
                {
                    Id = 1
                },
                new DbCategory()
                {
                    Id = 2
                }
            };

            mockProductContext.Setup(c => c.Products).ReturnsEntitySet(productList);
            mockProductContext.Setup(c => c.Categories).ReturnsEntitySet(categoryList);
            var service = new ProductCategoryService(mockProductContext.Object, mockUserContext.Object);

            var list = await service.GetCategoriesAsync(0, 2);

            Assert.Equal(2, list.Count);
        }
        public async Task DeleteCategoryAsync_IdPresent_RequestedProductDeleted()
        {
            var mockUserContext            = new Mock <IUserContext>();
            var mockProductContext         = new Mock <IProductCatalogueContext>();
            List <DbCategory> categoryList = new List <DbCategory>()
            {
                new DbCategory()
                {
                    Id = 1, IsDeleted = true
                },
                new DbCategory()
                {
                    Id = 2
                }
            };

            mockProductContext.Setup(c => c.Categories).ReturnsEntitySet(categoryList);
            mockProductContext.Setup(c => c.Products).ReturnsEntitySet(new List <CatalogueProduct>());
            var service = new ProductCategoryService(mockProductContext.Object, mockUserContext.Object);

            await service.DeleteCategoryAsync(1);

            var categories = await service.GetCategoriesAsync(0, categoryList.Count);

            Assert.DoesNotContain(categories, h => h.Id == 1);
        }
        public async Task SetStatusAsync_IdPresent_RequestedProductStatusChanged()
        {
            var mockUserContext            = new Mock <IUserContext>();
            var mockProductContext         = new Mock <IProductCatalogueContext>();
            List <DbCategory> categoryList = new List <DbCategory>()
            {
                new DbCategory()
                {
                    Id = 1
                },
                new DbCategory()
                {
                    Id = 2
                }
            };

            mockProductContext.Setup(c => c.Categories).ReturnsEntitySet(categoryList);
            mockUserContext.Setup(c => c.UserId).Returns(1);
            var service = new ProductCategoryService(mockProductContext.Object, mockUserContext.Object);

            await service.SetStatusAsync(1, false);

            var product = await service.GetCategoryAsync(1);

            Assert.False(product.IsDeleted);
        }
        public async Task UpdateCategoryAsync_IdNotPresent_RequestedResourceNotFoundExceptionThrown()
        {
            var newCategory = new UpdateProductCategoryRequest()
            {
                Code = "bb"
            };
            var mockUserContext            = new Mock <IUserContext>();
            var mockProductContext         = new Mock <IProductCatalogueContext>();
            List <DbCategory> categoryList = new List <DbCategory>()
            {
                new DbCategory()
                {
                    Id = 1
                },
                new DbCategory()
                {
                    Id = 2
                }
            };

            mockProductContext.Setup(c => c.Categories).ReturnsEntitySet(categoryList);
            var service = new ProductCategoryService(mockProductContext.Object, mockUserContext.Object);

            Assert.ThrowsAsync <RequestedResourceNotFoundException>(() => service.UpdateCategoryAsync(3, newCategory));
        }
        public async Task UpdateCategoryAsync_ValidRequest_ProductUpdated()
        {
            var newCategory = new UpdateProductCategoryRequest()
            {
                Code = "cc"
            };
            var mockUserContext            = new Mock <IUserContext>();
            var mockProductContext         = new Mock <IProductCatalogueContext>();
            List <DbCategory> categoryList = new List <DbCategory>()
            {
                new DbCategory()
                {
                    Id = 1
                },
                new DbCategory()
                {
                    Id = 2
                }
            };

            mockProductContext.Setup(c => c.Categories).ReturnsEntitySet(categoryList);
            mockUserContext.Setup(c => c.UserId).Returns(1);
            var service = new ProductCategoryService(mockProductContext.Object, mockUserContext.Object);

            var updatedProduct = await service.UpdateCategoryAsync(1, newCategory);

            Assert.Equal(newCategory.Code, updatedProduct.Code);
        }
        public async Task GetCategoryAsync_IdPresent_RequestedCategoryReturned()
        {
            var mockUserContext    = new Mock <IUserContext>();
            var mockProductContext = new Mock <IProductCatalogueContext>();
            List <CatalogueProduct> productList = new List <CatalogueProduct>()
            {
                new CatalogueProduct()
                {
                    Id = 1, CategoryId = 1
                },
                new CatalogueProduct()
                {
                    Id = 2, CategoryId = 2
                }
            };
            List <DbCategory> categoryList = new List <DbCategory>()
            {
                new DbCategory()
                {
                    Id = 1
                },
                new DbCategory()
                {
                    Id = 2
                }
            };

            mockProductContext.Setup(c => c.Products).ReturnsEntitySet(productList);
            mockProductContext.Setup(c => c.Categories).ReturnsEntitySet(categoryList);
            var service = new ProductCategoryService(mockProductContext.Object, mockUserContext.Object);

            var category = await service.GetCategoryAsync(1);

            Assert.Equal(1, category.Id);
        }
        public async Task CreateCategoryAsync_UniqueCode_ProductWithSpecifiedCodeCreated()
        {
            const string newCode     = "cc";
            var          newCategory = new UpdateProductCategoryRequest()
            {
                Code = newCode
            };
            var mockUserContext            = new Mock <IUserContext>();
            var mockProductContext         = new Mock <IProductCatalogueContext>();
            List <DbCategory> categoryList = new List <DbCategory>()
            {
                new DbCategory()
                {
                    Id = 1
                },
                new DbCategory()
                {
                    Id = 2
                }
            };

            mockProductContext.Setup(c => c.Categories).ReturnsEntitySet(categoryList);
            mockUserContext.Setup(c => c.UserId).Returns(1);
            var service = new ProductCategoryService(mockProductContext.Object, mockUserContext.Object);

            var product = await service.CreateCategoryAsync(newCategory);

            Assert.Equal(newCode, product.Code);
        }
示例#24
0
        public ActionResult FindTreeList()
        {
            int count = 0;
            var list  = ProductCategoryService.GetPageList(Request.Params, out count);

            list.Each(o => {
                o.Childrens.Each(i =>
                {
                    i.OnOff = i.Childrens != null && i.Childrens.Any()? "closed":"open";
                });
            });
            var trees = new List <ProductCategory>()
            {
                new ProductCategory()
                {
                    Id        = 0,
                    Title     = "商品分类",
                    OnOff     = "open",
                    Childrens = new List <ProductCategory>()
                }
            };

            trees[0].Childrens.AddRange(list);
            return(new JsonNetResult(trees));
        }
示例#25
0
        public ActionResult Detail(int?id, string supplierId)
        {
            ViewBag.companys = ListToSelect(WarehouseService.GetList().Select(o => new SelectListItem()
            {
                Value = o.StoreId, Text = o.Title
            }));
            ViewBag.parenttypes = ListToSelect(ProductCategoryService.GetParentTypes().Select(o => new SelectListItem()
            {
                Value = o.Id.ToString(), Text = o.Title
            }), emptyTitle: "请选择");
            ViewBag.suppliers = ListToSelect(SupplierService.GetList().Where(o => o.BusinessType == 1 && o.MasterState == 1).Select(o => new SelectListItem()
            {
                Value = o.Id, Text = o.FullTitle, Selected = o.Id == supplierId
            }));
            var obj  = OrderService.FindById(id);
            var user = UserInfoService.Find(o => o.UID == obj.CreateUID);

            if (user != null)
            {
                ViewData["creator"] = user.FullName;
            }
            user = UserInfoService.Find(o => o.UID == obj.RecipientsUID);
            if (user != null)
            {
                ViewData["reciptor"] = user.FullName;
            }
            return(View(obj));
        }
示例#26
0
        public ActionResult Products()
        {
            var sitemapItems = new List <SitemapItem>();

            String key = String.Format("ProductSitemapItemCache-{0}", StoreId);

            ProductSitemapItemCache.TryGet(key, out sitemapItems);

            if (sitemapItems == null)
            {
                sitemapItems = new List <SitemapItem>();
                var products   = ProductRepository.GetProductByTypeAndCategoryIdFromCache(StoreId, StoreConstants.ProductType, -1);
                var categories = ProductCategoryService.GetProductCategoriesByStoreIdFromCache(StoreId,
                                                                                               StoreConstants.ProductType);
                foreach (var product in products)
                {
                    var cat = categories.FirstOrDefault(r => r.Id == product.ProductCategoryId);
                    if (cat != null)
                    {
                        var productDetailLink = LinkHelper.GetProductIdRouteValue(product, cat.Name);
                        var siteMap           = new SitemapItem(Url.AbsoluteAction("Product", "Products", new { id = productDetailLink }),
                                                                changeFrequency: SitemapChangeFrequency.Monthly, priority: 1.0);
                        sitemapItems.Add(siteMap);
                    }
                }
                ProductSitemapItemCache.Set(key, sitemapItems, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.CacheLongSeconds));
            }
            return(new SitemapResult(sitemapItems));
        }
示例#27
0
        public async Task <ActionResult> Index3(int page = 1, int catId = 0, String search = "", String filters = "")
        {
            try
            {
                if (!IsModulActive(StoreConstants.ProductType))
                {
                    return(HttpNotFound("Not Found"));
                }

                var pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, IndexPageDesingName);
                var pageSize       = GetSettingValueInt("ProductsIndex_PageSize", StoreConstants.DefaultPageSize);
                var productsTask   = ProductService.GetProductsCategoryIdAsync(StoreId, catId, StoreConstants.ProductType, true, page, pageSize, search, filters);
                var categoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true);

                var settings = GetStoreSettings();
                ProductService2.ImageWidth  = GetSettingValueInt("ProductsIndex_ImageWidth", 50);
                ProductService2.ImageHeight = GetSettingValueInt("ProductsIndex_ImageHeight", 50);


                await Task.WhenAll(pageDesignTask, productsTask, categoriesTask);

                var products   = productsTask.Result;
                var pageDesign = pageDesignTask.Result;
                var categories = categoriesTask.Result;



                if (pageDesign == null)
                {
                    throw new Exception("PageDesing is null:" + IndexPageDesingName);
                }


                var pageOutput           = ProductService2.GetProductsIndexPage(products, pageDesign, categories);
                var pagingPageDesignTask = PageDesignService.GetPageDesignByName(StoreId, "Paging");


                PagingService2.PageOutput      = pageOutput;
                PagingService2.HttpRequestBase = this.Request;
                PagingService2.RouteData       = this.RouteData;
                PagingService2.ActionName      = this.ControllerContext.RouteData.Values["action"].ToString();
                PagingService2.ControllerName  = this.ControllerContext.RouteData.Values["controller"].ToString();
                await Task.WhenAll(pagingPageDesignTask);

                var pagingDic = PagingService2.GetPaging(pagingPageDesignTask.Result);
                pagingDic.StoreSettings = settings;
                pagingDic.PageTitle     = "Products";
                pagingDic.MyStore       = this.MyStore;



                return(View(pagingDic));
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "ProductsController:Index:" + ex.StackTrace, page);
                return(new HttpStatusCodeResult(500));
            }
        }
        // GET: Admin/ProductCategoryAdmin
        public ActionResult Index(string search, int page = 1, int pageSize = 5)
        {
            var service = new ProductCategoryService();
            var model   = service.DanhSachSPPaging(search).ToPagedList(page, pageSize);

            ViewBag.Search = search;
            return(View(model));
        }
示例#29
0
 public ActionResult SelectType2()
 {
     ViewBag.parenttypes = ListToSelect(ProductCategoryService.GetParentTypes().Select(o => new SelectListItem()
     {
         Value = o.CategorySN.ToString(), Text = o.Title
     }), emptyTitle: "请选择");
     return(View());
 }
示例#30
0
 public ProductAdminController()
 {
     this.publishingService      = new PublishingService <auRant.Core.Entities.Product, DraftProduct, ProductRepository>(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.productCategoryService = new ProductCategoryService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.productStatusService   = new ProductStatusService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.supplierService        = new SupplierService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.helperService          = new HelperService();
 }
示例#31
0
 public ProductAdminController()
 {
     this.publishingService = new PublishingService<auRant.Core.Entities.Product, DraftProduct, ProductRepository>(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.productCategoryService = new ProductCategoryService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.productStatusService = new ProductStatusService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.supplierService = new SupplierService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.helperService = new HelperService();
 }