protected IQueryable <T> FilterTypes(IQueryable <T> source) { IEnumerable <ProductItemType> selectedTypeValues = ProductItemType.Where(type => type.Value).ToDictionary(pair => pair.Key, pair => pair.Value).Keys; if (selectedTypeValues.Any()) { source = source.Where(p => selectedTypeValues.Contains(p.ProductItemType)); } return(source); }
public virtual void DeleteProductItemType(ProductItemType productItemType) { if (productItemType == null) { throw new ArgumentNullException("productItemType"); } _productItemTypeRepository.Delete(productItemType); _cacheManager.RemoveByPattern(PRODUCTITEMTYPES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(productItemType); }
public static Dictionary <ProductItemType, bool> GetSelectedProductItemTypeValues(Dictionary <ProductItemType, bool> dbValues, ProductItemType[] values, string currentValues) { if (values.Any()) { dbValues = dbValues.Select(s => values.Contains(s.Key) ? new KeyValuePair <ProductItemType, bool>(s.Key, true) : s).ToDictionary(pair => pair.Key, pair => pair.Value); } else { if (currentValues != default) { ICollection <ProductItemType> listOfTypes = new List <ProductItemType>(); foreach (var type in currentValues.Split(",")) { if (ProductItemType.TryParse(type, out ProductItemType result)) { listOfTypes.Add(result); } } dbValues = dbValues.Select(s => listOfTypes.Contains(s.Key) ? new KeyValuePair <ProductItemType, bool>(s.Key, true) : s).ToDictionary(pair => pair.Key, pair => pair.Value); } } return(dbValues); }