public async Task <int> LoadList()
        {
            //var genres = CurGenre.ID == 2 ? new int[] { } : new int[] { CurGenre.ID };
            var gfa = new int[GenreFilter.Count()];
            int i   = 0; foreach (var g in GenreFilter)
            {
                gfa[i++] = g.ID;
            }

            var users0 = new List <string>();

            if (UserA)
            {
                users0.Add("Alex");
            }
            if (UserM)
            {
                users0.Add("Mei");
            }
            if (UserN)
            {
                users0.Add("Nadine");
            }
            if (UserZ)
            {
                users0.Add("Zoe");
            }

            int tr = await onLoadList(gfa, users0.ToArray(), StringFilter, AddRandomDay);

            return(tr);
        }
        /// <inheritdoc />
        public async Task <MementoResponse <Page <GenreListContract> > > GetAllAsync(GenreFilter genreFilter = null)
        {
            var parameters = new Dictionary <string, string>();

            // Build the parameters
            if (genreFilter != null)
            {
                // Populate the filter parameters
                if (string.IsNullOrWhiteSpace(genreFilter.Name) == false)
                {
                    parameters.Add(nameof(genreFilter.Name), genreFilter.Name);
                }

                // Populate the pagination parameters
                parameters.Add(nameof(genreFilter.PageNumber), genreFilter.PageNumber.ToString());
                parameters.Add(nameof(genreFilter.PageSize), genreFilter.PageSize.ToString());
                parameters.Add(nameof(genreFilter.OrderBy), genreFilter.OrderBy.ToString());
                parameters.Add(nameof(genreFilter.OrderDirection), genreFilter.OrderDirection.ToString());
            }

            // Invoke the API
            var response = await this.HttpService.GetAsync <Page <GenreListContract> >($"{API_URL}", parameters);

            if (!response.Success)
            {
                throw new ApplicationException(string.Join(Environment.NewLine, response.Errors));
            }
            else
            {
                return(response);
            }
        }
示例#3
0
        /// <summary>
        /// Gets the items, using the provided Filter.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public async Task <IPaginatedEnumerable <GenreDto> > GetItems(GenreFilter filter)
        {
            var genreDtos = await this.api.GetGenres(filter);

            var items = genreDtos.ToList();

            return(new PaginatedEnumerable <GenreDto>(items, items.Count));
        }
示例#4
0
        /// <summary>
        /// Configures genres list query
        /// </summary>
        /// <param name="filter">genre filter</param>
        /// <returns>configured query</returns>
        private IQuery <GenreDTO> GetQuery(GenreFilter filter)
        {
            var query = genreListQuery;

            query.ClearSortCriterias();
            query.Filter = filter;
            return(query);
        }
        /// <summary>
        /// Callback that is invoked when the filter is reset.
        /// </summary>
        ///
        /// <param name="_">The filter.</param>
        private async Task OnFilterResetAsync(GenreFilter _)
        {
            // Reset the filter
            this.Filter = BuildDefaultFilter();

            // Update the genres
            await this.GetGenresAsync();
        }
        /// <summary>
        /// Callback that is invoked when the filter is applied.
        /// </summary>
        ///
        /// <param name="_">The filter.</param>
        private async Task OnFilterSearchAsync(GenreFilter _)
        {
            // Reset the paging
            this.Filter.PageNumber = 1;
            this.Filter.PageSize   = this.Filter.PageSize;

            // Update the genres
            await this.GetGenresAsync();
        }
示例#7
0
        /// <summary>
        /// Gets the genres, filtered by <see cref="filter" />.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public async Task <IEnumerable <GenreDto> > GetGenres(GenreFilter filter)
        {
            var request = new RequestBuilder()
                          .BaseUri(this.Url)
                          .AddQuery(nameof(filter.Skip), filter.Skip)
                          .AddQuery(nameof(filter.Take), filter.Take);

            if (!string.IsNullOrEmpty(filter.Search))
            {
                request.AddQuery(nameof(filter.Search), filter.Search);
            }
            return(await this.ExecuteAndParse <GenreDto[]>(request));
        }
示例#8
0
        public async Task <ServiceResponse <List <Genre> > > Get(GenreFilter model)
        {
            ExpressionStarter <Genre> expression = PredicateBuilder.New <Genre>(true);

            if (model.Name.Length > 0)
            {
                expression = expression.And(prop => model.Name.Contains(prop.Name));
            }
            var responseD = _genreRepo.Pagining(expression, ((model.PageNumber - 1) * model.PageSize), model.PageSize, model.OrderColumn, (OrderDirection)model.OrderBy, true);
            var response  = await responseD.ToListAsync();

            return(new ServiceResponse <List <Genre> >(response, true));
        }
        /// <summary>
        /// Builds the default filter from the built-in constants.
        /// </summary>
        private static GenreFilter BuildDefaultFilter()
        {
            // Create the filter
            var filter = new GenreFilter
            {
                PageNumber     = INITIAL_PAGE_NUMBER,
                PageSize       = INITIAL_PAGE_SIZE,
                OrderBy        = GenreFilterOrderBy.Name,
                OrderDirection = GenreFilterOrderDirection.Ascending
            };

            return(filter);
        }
示例#10
0
 public void Clear()
 {
     UserSearchFilter = "";
     ArtistFilter     = "";
     TitleFilter      = "";
     AlbumFilter      = "";
     if (GenreFilter.Any())
     {
         GenreFilter = new string[0];
     }
     FromYearFilter       = "";
     ToYearFilter         = "";
     RatingFilter         = 0;
     RatingFilterOperator = FilterOperator.Ignore;
 }
示例#11
0
        void onTglGenre(object gi)
        {
            Bpr.BeepOk();
            var intGnr = Convert.ToInt16(gi);
            var genre  = GenreFilter.FirstOrDefault(r => r.ID == intGnr);

            if (genre != null)
            {
                GenreFilter.Remove(genre);
            }
            else
            {
                GenreFilter.Add(Genres.FirstOrDefault(r => r.ID == intGnr));
            }
        }
示例#12
0
        /// <summary>
        /// Gets the genres from the backend matching the given name.
        /// </summary>
        ///
        /// <param name="name">The name.</param>
        private async Task <IEnumerable <GenreListContract> > GetGenresAsync(string name)
        {
            // Build the filter
            var genreFilter = new GenreFilter
            {
                Name           = name,
                OrderBy        = GenreFilterOrderBy.Name,
                OrderDirection = GenreFilterOrderDirection.Ascending
            };

            // Invoke the API
            var genres = await this.GenreService.GetAllAsync(genreFilter);

            // Filter the items
            return(genres.Data.Items.Where(item => this.Genres.All(genre => genre.Id != item.Id)));
        }
示例#13
0
        //VMState _VMState;
        public void SaveState()
        {
            var gfArray = new int[GenreFilter.Count()];
            var i       = 0; foreach (var g in GenreFilter)

            {
                gfArray[i++] = g.ID;
            }

            AppSettings.Instance.VMState = new Cmn.VMState
            {
                GenresFilter = gfArray,
                AddRandomDay = AddRandomDay,
                PlaylilstLen = PlaylilstLen,
                StringFilter = StringFilter,
                IsAutoPlay   = IsAutoPlay
            };
            AppSettings.Save();
        }
示例#14
0
        //VMState _VMState;
        public string SaveState()
        {
            var gfArray = new int[GenreFilter.Count()];
            int i       = 0; foreach (var g in GenreFilter)
            {
                gfArray[i++] = g.ID;
            }

            var vms = new VMState
            {
                GenreFilter  = gfArray,
                AddRandomDay = AddRandomDay,
                PlaylilstLen = PlaylilstLen,
                StringFilter = StringFilter,
                AutoStart    = AutoStart
            };

            return(Serializer.SaveToString(vms));
        }
示例#15
0
        public GenreListQueryResultDTO ListAllGenres(GenreFilter filter, int requiredPage = 1)
        {
            using (UnitOfWorkProvider.Create())
            {
                var query = GetQuery(filter);
                query.Skip = Math.Max(0, requiredPage - 1) * PageSize;
                query.Take = PageSize;

                var sortOrder = filter.SortAscending ? SortDirection.Ascending : SortDirection.Descending;
                query.AddSortCriteria(genre => genre.Name, sortOrder);

                return(new GenreListQueryResultDTO
                {
                    RequestedPage = requiredPage,
                    TotalResultCount = query.GetTotalRowCount(),
                    ResultsPage = query.Execute(),
                    Filter = filter
                });
            }
        }
示例#16
0
        public async Task <IEnumerable <GenreDto> > GetByFilter(GenreFilter filter)
        {
            var searchText = (filter.Search ?? string.Empty).ToLower();

            var query = await this.GetAll();

            if (!string.IsNullOrEmpty(searchText))
            {
                query = query.Where(g => g.Name.ToLower().Contains(searchText));
            }

            query = query.OrderBy(g => g.Id);

            //var totalCount = query.Count();
            //query = query.Skip(filter.Skip);
            //query = query.Take(filter.Take);
            var collection = await query.ToListAsync();

            return(collection.Select(g => g.ToDto()).ToList());
        }
示例#17
0
 public async Task <IHttpActionResult> Get([FromUri] GenreFilter filter = null)
 {
     filter = filter ?? new GenreFilter();
     return(await this.Try(() => this._genreRepository.GetByFilter(filter)));
 }
示例#18
0
        public void Check_That_GenreFilter_Returns_Right_Delegate()
        {
            // Arrange
            var genres = new List <Genre>
            {
                new Genre {
                    GenreId = 1
                },
                new Genre {
                    GenreId = 2
                },
                new Genre {
                    GenreId = 3
                },
                new Genre {
                    GenreId = 4
                },
            };

            var container = new GameFilterContainer
            {
                Model = new GamesFilterModel
                {
                    Genres = new List <int> {
                        1, 2
                    }
                }
            };

            var filter = new GenreFilter();

            var list = new List <Game>
            {
                new Game
                {
                    Genres = new List <Genre>
                    {
                        genres[0],
                        genres[1],
                    }
                },
                new Game
                {
                    Genres = new List <Genre>
                    {
                        genres[1],
                        genres[2],
                    }
                },
                new Game
                {
                    Genres = new List <Genre>
                    {
                        genres[2],
                        genres[3],
                    }
                },
                new Game
                {
                    Genres = new List <Genre>
                    {
                        genres[0],
                        genres[3],
                    }
                },
            };

            // Act
            filter.Execute(container);
            Func <Game, bool> resultCondition = CombinePredicate <Game> .CombineWithAnd(container.Conditions);

            IEnumerable <Game> result = list.Where(x => (resultCondition(x)));

            // Assert
            Assert.IsTrue(result.Count() == 3);
        }
示例#19
0
 public async Task <ServiceResponse <List <Genre> > > Get([FromQuery] GenreFilter request)
 {
     return(await _genreService.Get(request));
 }
示例#20
0
        public async Task <ActionResult <MementoResponse <IPage <GenreListContract> > > > GetAsync([FromQuery] GenreFilter filter)
        {
            // Get the genres
            var genres = await this.Repository.GetAllAsync(filter);

            // Build the response
            return(this.BuildGetAllResponse <Genre, GenreListContract>(genres));
        }