/// <summary> /// Gets product category mapping collection /// </summary> /// <param name="categoryId">Category identifier</param> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Product a category mapping collection</returns> public virtual IPagedList <ProductCategory> GetProductCategoriesByCategoryId(int categoryId, int currentCustomerId, int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false) { if (categoryId == 0) { return(new PagedList <ProductCategory>(new List <ProductCategory>(), pageIndex, pageSize)); } string key = string.Format(PRODUCTCATEGORIES_ALLBYCATEGORYID_KEY, showHidden, categoryId, pageIndex, pageSize, currentCustomerId, _storeContext.CurrentStore.Id); return(_cacheManager.GetCache(CACHE_NAME_PRODUCTCATEGORIES).Get(key, () => { var query = from pc in _productCategoryRepository.GetAll() join p in _productRepository.GetAll() on pc.ProductId equals p.Id where pc.CategoryId == categoryId && !p.Deleted && (showHidden || p.Published) orderby pc.DisplayOrder select pc; if (!showHidden && (!CatalogSettings.IgnoreAcl || !CatalogSettings.IgnoreStoreLimitations)) { //if (!_catalogSettings.IgnoreAcl) //{ // //ACL (access control list) // var allowedCustomerRolesIds = _workContext.CurrentCustomer.GetCustomerRoleIds(); // query = from pc in query // join c in _categoryRepository.Table on pc.CategoryId equals c.Id // join acl in _aclRepository.Table // on new { c1 = c.Id, c2 = "Category" } equals new { c1 = acl.EntityId, c2 = acl.EntityName } into c_acl // from acl in c_acl.DefaultIfEmpty() // where !c.SubjectToAcl || allowedCustomerRolesIds.Contains(acl.CustomerRoleId) // select pc; //} if (!CatalogSettings.IgnoreStoreLimitations) { //Store mapping var currentStoreId = _storeContext.CurrentStore.Id; query = from pc in query join c in _categoryRepository.GetAll() on pc.CategoryId equals c.Id join sm in _storeMappingRepository.GetAll() on new { c1 = c.Id, c2 = "Category" } equals new { c1 = sm.EntityId, c2 = sm.EntityName } into c_sm from sm in c_sm.DefaultIfEmpty() where !c.LimitedToStores || currentStoreId == sm.StoreId select pc; } //only distinct categories (group by ID) query = from c in query group c by c.Id into cGroup orderby cGroup.Key select cGroup.FirstOrDefault(); query = query.OrderBy(pc => pc.DisplayOrder); } var productCategories = new PagedList <ProductCategory>(query, pageIndex, pageSize); return productCategories; })); }
public IEnumerable <ProductCategory> GetAll(string filter) { IEnumerable <ProductCategory> listProductCategory; if (!string.IsNullOrEmpty(filter)) { listProductCategory = _productCategoryRepository.GetMulti(x => x.Name.Contains(filter)); } else { listProductCategory = _productCategoryRepository.GetAll(); } return(listProductCategory); }
/// <summary> /// To fetch all ProductCategories /// </summary> /// <returns></returns> public List <ProductCategory> GetProductCategories() { List <ProductCategory> productCategories; productCategories = _productCategoriesRepository.GetAll().ToList(); return(productCategories); }
public void SetForm(AddFromInventory form) { _form = form; _form.ProductCategories = _productCategoryRepository.GetAll(); _form.Inventories = _inventoryRepository.GetAll(); }
public void UpdateProductBase(ProductBase productBase, int selectedBrandId, IEnumerable <int> selectedCategoriesIds) { var product = _mapper.Map <ProductBase, Product>(productBase); product .BrandId = selectedBrandId; var existingProductCategories = _productCategoryRepository .GetAll() .Where( x => x.ProductId == productBase.Id ) .ToList(); _DeleteProductCategories( _GetToBeDeletedProductCategories(existingProductCategories, selectedCategoriesIds), product.Id ); _AddProductCategories( _GetToBeAddedProductCategories(existingProductCategories, selectedCategoriesIds), product.Id ); _productRepository .Update(product); _productRepository .Save(); _cache .Remove($"ProdFull:{product.Id}"); }
public IEnumerable <ProductCategory> GetAll(string keyword) { if (!String.IsNullOrEmpty(keyword)) { return(_productCategoryRepository.GetMulti(x => x.Name.Contains(keyword) || x.Description.Contains(keyword))); } return(_productCategoryRepository.GetAll());; }
public async Task <IList <ProductCategoryResponseModel> > GetAll() { var productCategories = await _productCategoryRepository .GetAll(); if (productCategories is null) { _notificationService.AddNotification("GetAllError", "Não há produtos cadastrados"); return(null); } return(productCategories.Select(d => new ProductCategoryResponseModel { SupplierName = d.Supplier.TradingName, CategoryName = d.CategoryName.ToString(), IsActive = d.IsActive ? "Sim" : "Não" }).ToList()); }
public void SetForm(Add form) { _form = form; _form.UnitOfMeasurements = _measurementRepository.GetAll(); _form.Storages = _storageRepository.GetAll(); _form.ProductCategories = _categoryRepository.GetAll(); }
public bool Create(ProductCategory obj) { List <ProductCategory> lstPC = productCategoryRepository.GetAll().ToList(); string productName = obj.ProductCategoryName.Trim().ToUpper().ToString(); var check = lstPC.Where(x => x.ProductCategoryName.ToUpper() == productName).FirstOrDefault(); if (check != null) { return(false); } int?orderBy = obj.DisplayOrder; obj.DisplayOrder = orderBy == null ? (lstPC.Count() + 1) : orderBy; productCategoryRepository.Create(obj); return(true); }
public GetAllProductCategoriesOutput GetAllProductCategories() { var productcategories = _ProductCategoryRepository.GetAll().OrderBy(b => b.CreationTime); return(new GetAllProductCategoriesOutput { ProductCategories = Mapper.Map <List <ProductCategoryDto> >(productcategories) }); }
public async Task <IViewComponentResult> InvokeAsync() { var categories = _memoryCache.GetOrCreate(CacheKeys.ProductCategories, entry => { entry.SlidingExpiration = TimeSpan.FromHours(2); return(_productCategoryRepository.GetAll()); }); return(View(categories)); }
public IEnumerable <ProductCategory> CheckBreadCrumb(string keyword) { List <ProductCategory> listCategory = new List <ProductCategory>(); var id = _productCategoryRepository.GetSingleByCondition(x => x.Name == keyword).ID; if (id == 1) { return(_productCategoryRepository.GetAll()); } string[] text = keyword.Split(' '); foreach (var item in text) { if (double.TryParse(item, out double a) == false) { listCategory.AddRange(_productCategoryRepository.GetMulti(x => x.Name.ToLower().Contains(item.ToLower()))); } } return(listCategory); }
public HttpResponseMessage getAll() { var productCategorys = productCategoryRepository.GetAll(); if (productCategorys == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, productCategorys)); }
public async Task <IEnumerable <ProductView> > Get() { var productCategories = await productCategoryRepository.GetAll(); var list = new List <ProductView>(); foreach (var item in productCategories) { list.Add(await productCategoryRepository.Get(item.ProductId, item.CategoryId)); } return(list); }
public List<CategoryModel> GetProductCategory() { var listCategory = _productCategoryRepository.GetAll().Select( x => new CategoryModel() { Id = x.Id, Name = x.Name, Image=x.Image, Url=x.Url, numberProduct = x.Products.Count() }).ToList(); return listCategory; }
public IEnumerable <ProductCategory> GetAll() { return(_productCategoryRepository.GetAll().OrderBy(x => x.DisplayOrder)); }
IEnumerable <ProductCategory> ICategoryService.GetAll() { return(_cateRepository.GetAll()); //throw new NotImplementedException(); }
public ICollection <ProductCategory> GetAll() { return(repository.GetAll()); }
public IActionResult GetAllCategories() { var model = _productCategoryRepository.GetAll(); return(new OkObjectResult(model)); }
public IEnumerable <ProductCategory> GetProductCategories() { var productCategories = productCategoryRepository.GetAll("ChildCategories"); return(productCategories); }
public void ProductCategory_Repository_GetAll() { var list = objRepository.GetAll().ToList(); Assert.AreEqual(1, list.Count); }
public IEnumerable <ProductCategory> GetAll() { return(_productCategoryRepository.GetAll().OrderBy(x => x.ParentID)); }
public IEnumerable <ProductCategory> GetAll() { return(_productCategoryRepository.GetAll(new string[] { "ParentProductCategory" })); }
public List <ProductCategory> GetProductCategories() { var ProductCategories = ProductCategorysRepository.GetAll().ToList(); return(ProductCategories); }
public List <ProductCategory> GetAll() { return(_productCategoryRepository.GetAll().ToList());; }
public IEnumerable <ProductCategory> GetAlls() { return(_productCategory.GetAll(null)); }
public IEnumerable <Models.DomainModels.ProductCategory> GetAllCategories() { return(prodCategoryRepository.GetAll().ToList()); }
public async Task <IList <ProductCategoryDto> > GetAll() { return(await _productCategoryRepository.GetAll()); }
public IEnumerable <ProductCategory> GetAll() { return(_ProductCategoryRepository.GetAll()); }
public IEnumerable <ProductCategory> GetProductCategories() { var productCategorys = productCategoryRepository.GetAll().Where(p => p.Deleted == false && p.Id != 14); return(productCategorys); }