public ActionResult GetFilters(Guid categoryId)
        {
            var characteristics = _catalog.GetAllChainCategoryCharacteristics(categoryId);
            var filterVMList    = new List <FilterVM>();

            foreach (var i in characteristics)
            {
                var filterVM = new FilterVM();
                filterVM.CharacteristicId   = i.Characteristic.Id;
                filterVM.CharacteristicName = i.Characteristic.Name;

                var filterCharValues = _catalog.GetCharValuesByCharacteristicId(filterVM.CharacteristicId);
                filterVM.ValuesList = new List <FilterCharValueVM>();
                foreach (var j in filterCharValues)
                {
                    var buff = new FilterCharValueVM();
                    buff.Id = j.Id;
                    buff.CharacteristicId = j.CharacteristicId;
                    buff.IntVal           = j.IntVal;
                    buff.FloatVal         = j.FloatVal;
                    buff.StrVal           = j.StrVal;
                    filterVM.ValuesList.Add(buff);
                }
                filterVMList.Add(filterVM);
            }

            return(PartialView(filterVMList));
        }
Ejemplo n.º 2
0
        public IEnumerable <TEntity> Filter(IEnumerable <TEntity> ads, FilterVM select)
        {
            IEnumerable <LaptopAd> laptops = (IEnumerable <LaptopAd>)ads;

            if (select.FromPrice != 0 || select.ToPrice != 0)
            {
                laptops = IFilterAdsStrategy <LaptopAd> .FilterPrice(laptops, select.FromPrice, select.ToPrice);
            }
            if (select.Brand?.Trim() != "" && select.Brand != null)
            {
                laptops = IFilterAdsStrategy <LaptopAd> .FilterBrand(laptops, select.Brand);
            }

            if (select.ScreenSize != 0)
            {
                laptops = laptops.Where(ad => ad.ScreenSize == select.ScreenSize);
            }
            if (select.RAM != 0)
            {
                laptops = laptops.Where(ad => ad.RAM == select.RAM);
            }
            if (select.DriveVolume != 0)
            {
                laptops = laptops.Where(ad => ad.DriveVolume == select.BatteryCapacity);
            }

            return((IEnumerable <TEntity>)laptops);
        }
Ejemplo n.º 3
0
        public IEnumerable <TEntity> Filter(IEnumerable <TEntity> ads, FilterVM select)
        {
            IEnumerable <RAMAd> drives = (IEnumerable <RAMAd>)ads;

            if (select.FromPrice != 0 || select.ToPrice != 0)
            {
                drives = IFilterAdsStrategy <RAMAd> .FilterPrice(drives, select.FromPrice, select.ToPrice);
            }
            if (select.Brand?.Trim() != "" && select.Brand != null)
            {
                drives = IFilterAdsStrategy <RAMAd> .FilterBrand(drives, select.Brand);
            }

            if (select.TotalCapacity != 0)
            {
                drives = drives.Where(ad => ad.TotalCapacity == select.TotalCapacity);
            }
            if (select.ModulesAmount != 0)
            {
                drives = drives.Where(ad => ad.ModulesAmount == select.ModulesAmount);
            }
            if (select.MemoryType?.Trim() != "" && select.MemoryType != null)
            {
                drives = drives.Where(ad => ad.MemoryType == select.MemoryType);
            }

            return((IEnumerable <TEntity>)drives);
        }
Ejemplo n.º 4
0
        public IEnumerable <TEntity> Filter(IEnumerable <TEntity> ads, FilterVM select)
        {
            IEnumerable <MonitorAd> monitors = (IEnumerable <MonitorAd>)ads;

            if (select.FromPrice != 0 || select.ToPrice != 0)
            {
                monitors = IFilterAdsStrategy <MonitorAd> .FilterPrice(monitors, select.FromPrice, select.ToPrice);
            }
            if (select.Brand?.Trim() != "" && select.Brand != null)
            {
                monitors = IFilterAdsStrategy <MonitorAd> .FilterBrand(monitors, select.Brand);
            }

            if (select.ScreenSize != 0)
            {
                monitors = monitors.Where(ad => ad.ScreenSize == select.ScreenSize);
            }
            if (select.Resolution?.Trim() != "" && select.Resolution != null)
            {
                monitors = monitors.Where(ad => ad.Resolution == select.MemoryType);
            }
            if (select.RefreshRate != 0)
            {
                monitors = monitors.Where(ad => ad.RefreshRate == select.RefreshRate);
            }

            return((IEnumerable <TEntity>)monitors);
        }
Ejemplo n.º 5
0
        public ActionResult SearchTours(FilterVM searchVM)
        {
            var mapFilter = _mapper.Map <DataSearchBL, FilterVM>(_tourService.GetDataSearch());

            if (ModelState.IsValid)
            {
                var searchTours    = _tourService.GetSearchTour(_mapper.Map <DataFilterVM, DataFilterBL>(searchVM.DataFilterVm));
                var mapSearchTours = _mapper.Map <IEnumerable <TourBL>, IEnumerable <TourVM> >(searchTours);
                return(View(new DataSearchVM
                {
                    Filter = mapFilter,
                    Tours = new ToursVM
                    {
                        Tours = mapSearchTours
                    }
                }));
            }

            var tours    = _tourService.GetHotTours();
            var maptours = _mapper.Map <IEnumerable <TourBL>, IEnumerable <TourVM> >(tours);

            return(View(new DataSearchVM
            {
                Filter = mapFilter,
                Tours = new ToursVM
                {
                    Tours = maptours
                }
            }));
        }
Ejemplo n.º 6
0
        public ActionResultVM GetUsers(FilterVM dataTablesParameters)
        {
            ActionResultVM obj    = new ActionResultVM();
            var            length = (int)dataTablesParameters.Length;

            var recordsTotal = dbContext.tblUser.Count();

            var sortedData = mapper.Map <List <UserVM> >(dbContext.tblUser)
                             .Where(x => (x.FirstName).ToUpper().Contains((dataTablesParameters.search.Value).ToUpper()) ||
                                    (x.LastName).ToUpper().Contains((dataTablesParameters.search.Value).ToUpper()));

            sortedData = GetOrderBy(sortedData, dataTablesParameters.Order[0]).Skip((int)dataTablesParameters.Start)
                         .Take(length);

            var columnFilteredData = GetSorted(dbContext.tblUser, dataTablesParameters.Columns);

            if (columnFilteredData != null && dataTablesParameters.search.Value == "")
            {
                obj.Data = mapper.Map <List <UserVM> >((columnFilteredData).Skip((int)dataTablesParameters.Start)
                                                       .Take(length).ToList());
                obj.TotalData = recordsTotal;
                return(obj);
            }
            obj.Data      = sortedData.ToList();
            obj.TotalData = recordsTotal;
            return(obj);
        }
Ejemplo n.º 7
0
        public IEnumerable <TEntity> Filter(IEnumerable <TEntity> ads, FilterVM select)
        {
            IEnumerable <SmartphoneAd> smartphones = (IEnumerable <SmartphoneAd>)ads;

            if (select.FromPrice != 0 || select.ToPrice != 0)
            {
                smartphones = IFilterAdsStrategy <SmartphoneAd> .FilterPrice(smartphones, select.FromPrice, select.ToPrice);
            }
            if (select.Brand?.Trim() != "" && select.Brand != null)
            {
                smartphones = IFilterAdsStrategy <SmartphoneAd> .FilterBrand(smartphones, select.Brand);
            }

            if (select.ScreenSize != 0)
            {
                smartphones = smartphones.Where(ad => ad.ScreenSize == select.ScreenSize);
            }
            if (select.RAM != 0)
            {
                smartphones = smartphones.Where(ad => ad.RAM == select.RAM);
            }
            if (select.BatteryCapacity != 0)
            {
                smartphones = smartphones.Where(ad => ad.BatteryCapacity == select.BatteryCapacity);
            }

            return((IEnumerable <TEntity>)smartphones);
        }
Ejemplo n.º 8
0
 public FilterVMData(FilterVM vm)
 {
     CanReorder         = vm.CanReorder;
     CanDelete          = vm.CanDelete;
     UnderlayingFilter  = vm.UnderlayingFilter;
     FilterDataProvider = vm.DataVM;
     Name = vm.Name;
 }
Ejemplo n.º 9
0
        public FilterVM CreateNewFilter()
        {
            GrayscaleFilter concrete = new GrayscaleFilter();
            FilterVM        vm       = new FilterVM(concrete);

            vm.Name = "New Grayscale Filter";
            return(vm);
        }
        public StatisticsCollectionVM(IStatisticsManager statisticsManager)
        {
            this.statisticsManager = statisticsManager;
            defaultFilter          = statisticsManager.GetDefaultFilter();

            // initialise filter with default values
            filterVM = new FilterVM(defaultFilter);
            LoadAvailableStatistics();
        }
Ejemplo n.º 11
0
 public FiltersWindow(int eventId)
 {
     this.eventId   = eventId;
     this.filterVM  = new FilterVM(eventId);
     this.newFilter = null;
     this.filterIds = new Dictionary <int, int>();
     this.stopProcessSelectionChanged = new Dictionary <string, bool>();
     this.deletedFilters = new HashSet <int>();
     InitializeComponent();
     InitializeFilterScreen();
 }
Ejemplo n.º 12
0
        private async void DownloadFullMatchData(MatchModel param)
        {
            ConnectionStatus = Properties.Resources.tinder_update_getting_matches;

            var updatedMatch = await TinderHelper.GetFullMatchData(param.Person.Id);

            SerializationHelper.UpdateMatchModel(param, updatedMatch);
            new Task(() => SerializationHelper.SerializeMatch(param)).Start();

            ConnectionStatus = Properties.Resources.tinder_auth_okay;
            FilterVM.SortMatchList();
        }
        async void GetFilters()
        {
            FilterApiService      service = new FilterApiService();
            List <FNameViewModel> list    = await service.GetFiltersAsync();

            FilterVM.Clear();
            FilterVM.AddRange(list);
            CarApiService serviceCars = new CarApiService();
            var           listCars    = await serviceCars.GetCarsAsync();

            CarVM.Clear();
            CarVM.AddRange(listCars);
            FillFiltersWP();
            FillCarsWP();
            Spinner.Opacity = 0;
        }
Ejemplo n.º 14
0
        public FilterVM CreateNewFilter()
        {
            BasicMatrixFilter concreteFilter = new BasicMatrixFilter
                                                   (new double[3, 3] {
                { 1.0, 1.0, 1.0 },
                { 1.0, 1.0, 1.0 },
                { 1.0, 1.0, 1.0 }
            });


            FilterVM vm = new FilterVM(concreteFilter);

            vm.Name   = "New Basic Filter";
            vm.DataVM = new BasicMatrixFilterDataProviderVM(vm);

            return(vm);
        }
Ejemplo n.º 15
0
        public CacheCollectionVM(ICacheManager cacheManager)
        {
            this.cacheManager = cacheManager;

            // load list of cache sizes from db
            SizeList = cacheManager.GetCacheSizeList();

            // load default filter
            defaultFilter = cacheManager.GetDefaultFilter();

            // initialise active filter with default values and pass just loaded list of cache size to filter
            filterVM = new FilterVM(defaultFilter)
            {
                CacheSizeList = SizeList
            };

            Caches = new ObservableCollection <CacheVM>();
            LoadCaches(Filter.Current);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Removes matches with null value (don't know why they are there) and
        /// sorts by LastActivityDate in descending order
        /// </summary>
        private void MatchListSetup()
        {
            // Adds event handlers for each message list
            foreach (var item in MatchList)
            {
                item.Messages = item.Messages ?? new ObservableCollection <MessageModel>();

                // For when there are already handlers attached
                item.Messages.CollectionChanged -= Messages_CollectionChanged;
                item.Messages.CollectionChanged += Messages_CollectionChanged;
            }

            // Remove ghost matches, which I don't know why exist
            for (int i = 0; i < MatchList.Count; i++)
            {
                if (MatchList[i].Person == null)
                {
                    MatchList.RemoveAt(i--);
                }
            }

            FilterVM.SortMatchList();
        }
Ejemplo n.º 17
0
        public IEnumerable <TEntity> Filter(IEnumerable <TEntity> ads, FilterVM select)
        {
            IEnumerable <DriveAd> drives = (IEnumerable <DriveAd>)ads;

            if (select.FromPrice != 0 || select.ToPrice != 0)
            {
                drives = IFilterAdsStrategy <DriveAd> .FilterPrice(drives, select.FromPrice, select.ToPrice);
            }
            if (select.Brand?.Trim() != "" && select.Brand != null)
            {
                drives = IFilterAdsStrategy <DriveAd> .FilterBrand(drives, select.Brand);
            }

            if (select.Capacity != 0)
            {
                drives = drives.Where(ad => ad.Capacity == select.Capacity);
            }
            if (select.RPM != 0)
            {
                drives = drives.Where(ad => ad.RPM == select.RPM);
            }

            return((IEnumerable <TEntity>)drives);
        }
Ejemplo n.º 18
0
        public IEnumerable <TEntity> Filter(IEnumerable <TEntity> ads, FilterVM select)
        {
            IEnumerable <ProcessorAd> processors = (IEnumerable <ProcessorAd>)ads;

            if (select.FromPrice != 0 || select.ToPrice != 0)
            {
                processors = IFilterAdsStrategy <ProcessorAd> .FilterPrice(processors, select.FromPrice, select.ToPrice);
            }
            if (select.Brand?.Trim() != "" && select.Brand != null)
            {
                processors = IFilterAdsStrategy <ProcessorAd> .FilterBrand(processors, select.Brand);
            }

            if (select.CoresAmount != 0)
            {
                processors = processors.Where(ad => ad.CoresAmount == select.CoresAmount);
            }
            if (select.ClockSpeed != 0)
            {
                processors = processors.Where(ad => ad.ClockSpeed == select.ClockSpeed);
            }

            return((IEnumerable <TEntity>)processors);
        }
Ejemplo n.º 19
0
        public IEnumerable <TEntity> Filter(IEnumerable <TEntity> ads, FilterVM select)
        {
            IEnumerable <VideocardAd> videocards = (IEnumerable <VideocardAd>)ads;

            if (select.FromPrice != 0 || select.ToPrice != 0)
            {
                videocards = IFilterAdsStrategy <VideocardAd> .FilterPrice(videocards, select.FromPrice, select.ToPrice);
            }
            if (select.Brand?.Trim() != "" && select.Brand != null)
            {
                videocards = IFilterAdsStrategy <VideocardAd> .FilterBrand(videocards, select.Brand);
            }

            if (select.MemorySize != 0)
            {
                videocards = videocards.Where(ad => ad.MemorySize == select.MemorySize);
            }
            if (select.MemoryType?.Trim() != "" && select.MemoryType != null)
            {
                videocards = videocards.Where(ad => ad.MemoryType == select.MemoryType);
            }

            return((IEnumerable <TEntity>)videocards);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Загружает данные с БД
        /// </summary>
        /// <param name="page">Указывает страницу для загрузки или загружать все</param>
        /// <param name="tableRows"></param>
        /// <param name="tablePages"></param>
        /// <param name="pageShowRows"></param>
        /// <returns></returns>
        private DataView GetData(DataView data, int?page, out int tableRows, out int tablePages, out int pageShowRows, FilterRelationModel filterPattern = null)
        {
            tableRows    = GetCountRows();
            pageShowRows = 0;
            if (page != null)
            {
                tablePages = tableRows / __pageMaxRows;
                if (tableRows % __pageMaxRows > 0)
                {
                    tablePages++;
                }
            }
            else
            {
                tablePages = 1;
            }
            if (tableRows != 0)
            {
                using (SqlWork sqlCmd = new SqlWork(_connect, _isDebug))
                {
                    List <IParams> listParams   = new List <IParams>();
                    string         whereDynamic = PgTableViewFilterVM.GetWhere(FilterVM.DynamicFilter, listParams);
                    string         whereFixed   = PgTableViewFilterVM.GetWhere(FilterVM.FixedFilter, listParams);
                    string         whereUpdated = "1 = 1";
                    if (filterPattern != null)
                    {
                        PgTVM.PgTableViewFilterM filterUpdated = new PgTableViewFilterM(FilterVM);
                        FilterVM.SetFilterFromPattern(filterUpdated, filterPattern);
                        whereUpdated = PgTableViewFilterVM.GetWhere(filterUpdated, listParams);
                    }
                    sqlCmd.sql =
                        string.Format(
                            @"
                                    SELECT *
                                    FROM (
                                        SELECT *
                                        FROM (
                                            {0}
                                            ) as gg 
                                        WHERE {1} AND {2} 
                                        ORDER BY {3}
                                        {4}
                                    ) s
                                    WHERE {5}",
                            sqlSelect,
                            whereFixed,
                            whereDynamic,
                            GetSQLOrderBy(data),
                            (page == null) ? "" : string.Format("LIMIT {0} OFFSET {1}", __pageMaxRows, ((int)page - 1) * __pageMaxRows),
                            whereUpdated);

                    data = sqlCmd.ExecuteGetTable(data, listParams);
                }
            }
            if (data != null)
            {
                pageShowRows = data.Table.Rows.Count;
                if (data.Sort == "")
                {
                    data.Sort = _table.PrimaryKey;
                }
            }
            return(data);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// First thing called. Entry point of some sort. Calls other methods to get Tinder data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void StartInitialize(object sender, EventArgs e)
        {
            ConnectionStatus = Resources.tinder_auth_connecting;

            // Only do full authorization if it's the first time or data is not saved yet
            if (string.IsNullOrEmpty(UserName))
            {
                if (await Authenticate(FbId, FbToken))
                {
                    UserName = User.ToString();

                    string lat = "0";
                    string lon = "0";

                    if (User.Pos != null)
                    {
                        lat = User.Pos.Latitude.Replace('.', ',');
                        lon = User.Pos.Longtitude.Replace('.', ',');
                    }

                    SerializationHelper.CreateUser(FbId, FbToken, UserName, User.LatestUpdateDate,
                                                   lat, lon);
                    SerializationHelper.UpdateTinderToken(Auth.Token);


                    // Gets matches
                    await GetMatches();

                    // Gets recs
                    await GetRecs();

                    int time = MatchList.Count * 3 / 60;
                    // Dont ask just save nobody cares what user wants
                    MessageBox.Show($"All your matches will be saved. It may take up to {time} minutes "
                                    + "for the download to complete. I recommend not to cancel this action.",
                                    "Downloading data", MessageBoxButton.OK, MessageBoxImage.Information);

                    Messenger.Default.Send(new SerializationPacket(MatchList, RecList, User),
                                           MessengerToken.ShowSerializationDialog);

                    Settings.Default["FirstStart"] = false;
                    Settings.Default.Save();

                    StartUpdatingMatches();
                    StartUpdatingRecs();
                    ConnectionStatus = Resources.tinder_auth_okay;
                }
            }
            // It's not the first time launching application
            else
            {
                SerializationHelper.CurrentUser = UserName;


                // FIXME hangs application for a second
                // Deserializes matches and recs first
                MatchList = SerializationHelper.DeserializeMatchList();


                MatchListSetup();
                FilterVM.UpdateStatusBar();

                RecList = SerializationHelper.DeserializeRecList();

                if (await Authenticate(FbId, FbToken))
                {
                    string lat = "0";
                    string lon = "0";

                    if (User.Pos != null)
                    {
                        lat = User.Pos.Latitude.Replace('.', ',');
                        lon = User.Pos.Longtitude.Replace('.', ',');
                        SerializationHelper.UpdateUserPosition(lat, lon);
                    }


                    SerializationHelper.UpdateTinderToken(Auth.Token);

                    // Updates last five matches
                    Parallel.ForEach(MatchList.OrderByDescending(x => x.LastActivityDate).Take(5), async x =>
                    {
                        try
                        {
                            var updatedMatch = await TinderHelper.GetFullMatchData(x.Person.Id);
                            SerializationHelper.UpdateMatchModel(x, updatedMatch);
                            new Task(() => SerializationHelper.SerializeMatch(x)).Start();
                        }
                        catch (TinderRequestException ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    });

                    FilterVM.SortMatchList();

                    UpdateMatches(this, null);
                    UpdateRecs(this, null);

                    ConnectionStatus = Resources.tinder_auth_okay;

                    // Starts automatic updates
                    StartUpdatingMatches();
                    StartUpdatingRecs();
                }
                else
                {
                    ConnectionStatus = Resources.tinder_auth_error;
                }
            }

            // Now we check if there's a new version available
            var restClient = new RestClient("https://api.github.com/");
            var request    = new RestRequest("repos/dainius14/twinder/releases/latest", Method.GET);
            var response   = await restClient.ExecuteTaskAsync(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var json = JsonConvert.DeserializeObject <dynamic>(response.Content);
                if (!("v" + Assembly.GetExecutingAssembly().GetName().Version.ToString()).StartsWith((string)json.tag_name))
                {
                    Messenger.Default.Send((string)json.html_url, MessengerToken.ShowUpdateAvailableDialog);
                }
            }
        }
        private static IEnumerable <Customer> FilterWithRegistrationDate(IEnumerable <Customer> orderList, FilterVM filter)
        {
            if ((!String.IsNullOrEmpty(filter.ColumnName)) && (filter.ColumnName.ToUpper() == "REGISTRATIONDATE"))
            {
                if (!String.IsNullOrEmpty(filter.StartDate))
                {
                    DateTime dateToCompare;
                    if (DateTime.TryParse(filter.StartDate, out dateToCompare))
                    {
                        if ((filter.SearchType.ToUpper() == "EQUALS") || (filter.SearchType == "="))
                        {
                            orderList = orderList.Where(s => s.RegistrationDate.Date == dateToCompare.Date).ToList();
                        }

                        else if (filter.SearchType.ToUpper() == "BEFORE")
                        {
                            orderList = orderList.Where(s => s.RegistrationDate.Date < dateToCompare.Date).ToList();
                        }

                        else if (filter.SearchType.ToUpper() == "AFTER")
                        {
                            orderList = orderList.Where(s => s.RegistrationDate.Date > dateToCompare.Date).ToList();
                        }

                        else if (filter.SearchType.ToUpper() == "BETWEEN")
                        {
                            DateTime endDateToCompare;
                            if (DateTime.TryParse(filter.EndDate, out endDateToCompare))
                            {
                                orderList = orderList.Where(s => s.RegistrationDate.Date > dateToCompare.Date && s.RegistrationDate.Date < endDateToCompare.Date).ToList();
                            }
                        }
                    }
                }
            }
            return(orderList);
        }
Ejemplo n.º 23
0
        public IActionResult AdsPartial(int page, string category, string search, string sort, FilterVM filter)
        {
            if (sort == "own")
            {
                filter.UserId = (repo.GetUser(User.Identity.Name)).Id;
            }
            PageContainer container = repo.GetPage(category, page, search, sort, filter);

            AdsVM vm = new AdsVM(container.Ads, category, page, container.PageAmount);

            return(PartialView(vm));
        }
Ejemplo n.º 24
0
        private async void UpdateMatches(object sender, EventArgs e)
        {
            try
            {
                var newUpdates = await TinderHelper.GetUpdates(SerializationHelper.GetLastUpdate());

                if (newUpdates.Matches.Count != 0)
                {
                    SerializationHelper.UpdateLastUpdate(newUpdates.LastActivityDate);

                    foreach (var newMatch in newUpdates.Matches)
                    {
                        var matchToUpdate = MatchList.Where(item => item.Id == newMatch.Id).FirstOrDefault();

                        // There's an update to an existing match
                        if (matchToUpdate != null)
                        {
                            // Adds new messages the to list
                            foreach (var newMessage in newMatch.Messages)
                            {
                                if (!matchToUpdate.Messages.Contains(newMessage))
                                {
                                    matchToUpdate.Messages.Add(newMessage);
                                }
                            }

                            if (!UpdatedMatches.Contains(matchToUpdate))
                            {
                                UpdatedMatches.Add(matchToUpdate);
                            }

                            matchToUpdate.LastActivityDate = newMatch.LastActivityDate;

                            new Task(() => SerializationHelper.SerializeMatch(matchToUpdate)).Start();
                        }
                        // There's a new match
                        else
                        {
                            new Task(() => SerializationHelper.SerializeMatch(newMatch)).Start();
                            MatchList.Insert(0, newMatch);
                            NewMatchList.Add(newMatch);
                        }
                    }
                }

                if (newUpdates.Blocks.Count != 0)
                {
                    foreach (var unmatched in newUpdates.Blocks)
                    {
                        var match = MatchList.Where(x => x.Id == unmatched).FirstOrDefault();
                        if (match != null)
                        {
                            SerializationHelper.MoveMatchToUnMatched(match);
                            MatchList.Remove(match);
                            MessageBox.Show(match.Person.Name + " unmatched you");
                        }
                    }
                }

                FilterVM.SortMatchList();
            }
            catch (TinderRequestException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 25
0
        public PageContainer GetPage(string category, int page, string search, string sort, FilterVM filter)
        {
            int                   entitiesPerPage = 10;
            PageContainer         container       = new PageContainer();
            IEnumerable <TEntity> ads             = dbSet.Where(ad => ad.IsFreezed == false);

            // search
            ads = dbSet.Where(ad => ad.Title.Contains(search));

            // filter
            IFilterAdsStrategy <TEntity> filterAds = null;

            if (filter != null)
            {
                if (category == "smartphone")
                {
                    filterAds = new FilterSmartphones <TEntity>();
                }
                else if (category == "laptop")
                {
                    filterAds = new FilterLaptops <TEntity>();
                }
                else if (category == "monitor")
                {
                    filterAds = new FilterMonitors <TEntity>();
                }
                else if (category == "videocard")
                {
                    filterAds = new FilterVideocards <TEntity>();
                }
                else if (category == "processor")
                {
                    filterAds = new FilterProcessors <TEntity>();
                }
                else if (category == "RAM")
                {
                    filterAds = new FilterRAMs <TEntity>();
                }
                else if (category == "drive")
                {
                    filterAds = new FilterDrives <TEntity>();
                }
            }

            if (filterAds != null)
            {
                ads = filterAds.Filter(ads, filter);
            }

            // sort
            if (sort == "recent")
            {
                ads = ads.OrderByDescending(ad => ad.Id);
            }
            else if (sort == "decrease-price")
            {
                ads = ads.OrderByDescending(ad => ad.Price);
            }
            else if (sort == "increase-price")
            {
                ads = ads.OrderBy(ad => ad.Price);
            }
            else if (sort == "own")
            {
                ads = ads.Where(ad => ad.UserId == filter.UserId);
            }

            // pagination
            container.Ads        = ads.Skip((page - 1) * entitiesPerPage).Take(entitiesPerPage);
            container.PageAmount = (int)Math.Ceiling(ads.Count() / (double)entitiesPerPage);

            return(container);
        }
Ejemplo n.º 26
0
        public IActionResult GetUser([FromBody] FilterVM dataTablesParameters)
        {
            var userData = this.userRepository.GetUsers(dataTablesParameters);

            return(Ok(userData));
        }
        private static IEnumerable <Customer> FilterWithCity(IEnumerable <Customer> clientList, FilterVM filter)
        {
            if ((!String.IsNullOrEmpty(filter.ColumnName)) && (filter.ColumnName.ToUpper() == "CITY"))
            {
                if (!String.IsNullOrEmpty(filter.SearchText))
                {
                    if (filter.SearchType.ToUpper() == "CONTAINS")
                    {
                        clientList = clientList.Where(s => s.City.ToUpper().Contains(filter.SearchText.ToUpper())).ToList();
                    }

                    else if (filter.SearchType.ToUpper() == "STARTSWITH")
                    {
                        clientList = clientList.Where(s => s.City.StartsWith(filter.SearchText, StringComparison.InvariantCultureIgnoreCase)).ToList();
                    }

                    else if (filter.SearchType.ToUpper() == "ENDSWITH")
                    {
                        clientList = clientList.Where(s => s.City.EndsWith(filter.SearchText, StringComparison.InvariantCultureIgnoreCase)).ToList();
                    }

                    else if ((filter.SearchType.ToUpper() == "EQUALS") || (filter.SearchType == "="))
                    {
                        clientList = clientList.Where(s => s.City.Equals(filter.SearchText, StringComparison.InvariantCultureIgnoreCase)).ToList();
                    }
                }
            }
            return(clientList);
        }
Ejemplo n.º 28
0
        public PageContainer GetPage(string category, int page = 1, string search = "", string sort = "recent", FilterVM filter = null)
        {
            PageContainer container = new PageContainer();

            if (category == "smartphone")
            {
                container = smartphoneRepo.GetPage(category, page, search, sort, filter);
            }
            else if (category == "laptop")
            {
                container = laptopRepo.GetPage(category, page, search, sort, filter);
            }
            else if (category == "videocard")
            {
                container = videocardRepo.GetPage(category, page, search, sort, filter);
            }
            else if (category == "monitor")
            {
                container = monitorRepo.GetPage(category, page, search, sort, filter);
            }
            else if (category == "processor")
            {
                container = processorRepo.GetPage(category, page, search, sort, filter);
            }
            else if (category == "ram")
            {
                container = ramRepo.GetPage(category, page, search, sort, filter);
            }
            else if (category == "drive")
            {
                container = driveRepo.GetPage(category, page, search, sort, filter);
            }

            return(container);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// If there are new messages added to collection, updates the view
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Messages_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     FilterVM.SortMatchList();
 }