Beispiel #1
0
        public static VisitManufacturers CreateManufacturer(SelectedManufacturers data)
        {
            var manufacturer = new VisitManufacturers
            {
                ManufacturerId = data.Id,
                GroupId        = data.GroupId,
                Percent        = data.Percent
            };

            return(manufacturer);
        }
Beispiel #2
0
        /*private void SetBindsToNull()
         * {
         *  return await OnGet();
         * }*/
        private IQueryable <ProductEntity> GetProductEntities()
        {
            var result = _shopContext.Products
                         .AsNoTracking()
                         .Include(i => i.Images)
                         .Where(p =>
                                #region search string adapter
                                (string.IsNullOrEmpty(SearchString) || SearchString.Length < 3 ||
                                 p.DisplayName.ToLower().Contains(SearchString.ToLower()) ||
                                 p.Manufacturer.ToLower().Contains(SearchString.ToLower()))
                                #endregion
                                &&
                                #region manufacturer adapter
                                (SelectedManufacturers == null || !SelectedManufacturers.Any() ||
                                 SelectedManufacturers.Contains(p.Manufacturer.ToLower()))
                                #endregion
                                &&
                                #region OS adapter
                                (SelectedOperatingSystems == null || !SelectedOperatingSystems.Any() ||
                                 SelectedOperatingSystems.Contains(p.OperatingSystem.ToLower()))
                                #endregion
                                &&
                                #region RAM adapter
                                (SelectedRamList == null || !SelectedRamList.Any() ||
                                 SelectedRamList.Contains(p.Ram.Value))
                                #endregion
                                &&
                                #region ROM adapter
                                (SelectedRomList == null || !SelectedRomList.Any() ||
                                 SelectedRomList.Contains(p.Rom.Value))
                                #endregion
                                &&
                                #region battery capacity adapter
                                (!SelectedBatteryCapacity.HasValue || SelectedBatteryCapacity < 2500 ||
                                 SelectedBatteryCapacity >= 6000 && p.BatteryCapacity >= 6000 ||
                                 p.BatteryCapacity >= SelectedBatteryCapacity && p.BatteryCapacity < SelectedBatteryCapacity + 500)
                                #endregion
                                &&
                                #region price adapter
                                (!MinPrice.HasValue && !MaxPrice.HasValue ||
                                 !MinPrice.HasValue && MaxPrice.HasValue && p.Price <= MaxPrice ||
                                 !MaxPrice.HasValue && MinPrice.HasValue && p.Price >= MinPrice ||
                                 MinPrice.HasValue && MaxPrice.HasValue && p.Price >= MinPrice && p.Price <= MaxPrice)
                                #endregion
                                &&
                                #region display diagonal adapter
                                (!SelectedScreenSize.HasValue || SelectedScreenSize < 4 ||
                                 SelectedScreenSize >= 7 && p.DisplayDiagonal >= 7 ||
                                 p.DisplayDiagonal >= SelectedScreenSize && p.DisplayDiagonal <= SelectedScreenSize + 0.5)
                                #endregion
                                &&
                                #region weight adapter
                                (!SelectedWeight.HasValue || SelectedWeight <= 100 && p.Weight <= 100 ||
                                 SelectedWeight > 300 && p.Weight > 300 ||
                                 p.Weight >= SelectedWeight && p.Weight < SelectedWeight + 50)
                                #endregion
                                &&
                                #region additonal filters
                                (!HasNFC || p.HasNFC)
                                &&
                                (!HasSdCardSlot || p.HasSdCardSlot)
                                #endregion
                                )
                         .OrderByDescending(p => p.Price)
                         .ThenByDescending(p => p.Manufacturer);

            return(result);
        }