public ActionResult ListCategory(GridCommand command) { var records = _yandexMarketCategoryService.GetAll(command.Page - 1, command.PageSize); var categorysModel = records .Select(x => { var m = new YandexMarketCategoryModel() { Id = x.Id, Name = x.Name, }; return(m); }) .ToList(); var model = new GridModel <YandexMarketCategoryModel> { Data = categorysModel, Total = records.TotalCount }; return(new JsonResult { Data = model }); }
private void UpdateCategory(YandexMarketCategoryModel model) { var category = _yandexMarketCategoryService.GetById(model.Id); category.Name = model.Name; category.Url = model.Url; category.IsActive = model.IsActive; _yandexMarketCategoryService.Update(category); }
public ActionResult UpdateCategory(YandexMarketCategoryModel model, GridCommand command) { var category = _yandexMarketCategoryService.GetById(model.Id); category.Name = model.Name; _yandexMarketCategoryService.Update(category); return(ListCategory(command)); }
public ActionResult ListCategory(bool isWithProductCountInCategories, GridCommand command) { var availableShopCategories = _shopCategoryService.GetAllCategories(); //.Select(x => new Dictionary<int, string>( x.Id, x.Name)).ToList(); var yaCategories = _yandexMarketCategoryService.GetAll(command.Page - 1, command.PageSize); var categorysModel = yaCategories .Select(currentYaCategory => { var shopCategory = availableShopCategories.SingleOrDefault(s => s.Id == currentYaCategory.ShopCategoryId); var shopCategoryName = ""; var numberOfProducts = 0; var notImportedRecords = 0; if (shopCategory != null) { shopCategoryName = shopCategory.Name; if (isWithProductCountInCategories) { numberOfProducts = this._productService.SearchProducts( categoryIds: new List <int>() { shopCategory.Id }, priceMin: 1, storeId: _storeContext.CurrentStore.Id, pageSize: 1).TotalCount; // посчитать сколько не импортировано еще notImportedRecords = _yandexMarketProductService.GetByCategory( categoryId: currentYaCategory.Id, isNotImportedOnly: true, pageIndex: command.Page - 1, pageSize: 1).TotalCount; } } else { shopCategoryName = "---"; currentYaCategory.ShopCategoryId = 0; } var m = new YandexMarketCategoryModel() { Id = currentYaCategory.Id, Name = currentYaCategory.Name, Url = currentYaCategory.Url, ShopCategoryId = currentYaCategory.ShopCategoryId, ShopCategoryName = shopCategoryName, IsActive = currentYaCategory.IsActive, AlreadyImportedProducts = numberOfProducts, NotImportedProducts = notImportedRecords, }; return(m); }) .ForCommand(command) .ToList(); var model = new GridModel <YandexMarketCategoryModel> { Data = categorysModel, Total = yaCategories.TotalCount }; return(new JsonResult { Data = model }); }
public ActionResult UpdateCategory(YandexMarketCategoryModel model, GridCommand command) { UpdateCategory(model); return(ListCategory(isWithProductCountInCategories: false, command: command)); }