public async Task <ActionResult <PagedCollectionResponse <Contact> > > Get([FromQuery] FilterModel filter) { var contacts = await _contactRepo.GetByPageIndex <Contact>(filter.Page, filter.Limit); //Filtering logic IEnumerable <Contact> filterData(FilterModel filterModel) => contacts; //Get the data for the current page var result = new PagedCollectionResponse <Contact>(); result.Items = filterData(filter); //Get next page URL string FilterModel nextFilter = filter.Clone() as FilterModel; nextFilter.Page += 1; String nextUrl = filterData(nextFilter).Count() <= 0 ? null : this.Url.Action("Get", null, nextFilter, Request.Scheme); //Get previous page URL string FilterModel previousFilter = filter.Clone() as FilterModel; previousFilter.Page -= 1; String previousUrl = previousFilter.Page <= 0 ? null : this.Url.Action("Get", null, previousFilter, Request.Scheme); result.NextPage = !String.IsNullOrWhiteSpace(nextUrl) ? new Uri(nextUrl) : null; result.PreviousPage = !String.IsNullOrWhiteSpace(previousUrl) ? new Uri(previousUrl) : null; return(result); }
public ActionResult <PagedCollectionResponse <Unit> > Get([FromQuery] FilterModel filter) { IEnumerable <Unit> unit = _dataRepository.GetAll(); //Filtering logic Func <FilterModel, IEnumerable <Unit> > filterData = (filterModel) => { return(unit.Where(p => p.Name.StartsWith(filterModel.Term ?? String.Empty, StringComparison.InvariantCultureIgnoreCase)) .Skip((filterModel.Page - 1) * filter.Limit) .Take(filterModel.Limit)); }; //Get the data for the current page var result = new PagedCollectionResponse <Unit>(); result.Items = filterData(filter); //Get next page URL string FilterModel nextFilter = filter.Clone() as FilterModel; nextFilter.Page += 1; String nextUrl = filterData(nextFilter).Count() <= 0 ? null : this.Url.Action("Get", null, nextFilter, Request.Scheme); //Get previous page URL string FilterModel previousFilter = filter.Clone() as FilterModel; previousFilter.Page -= 1; String previousUrl = previousFilter.Page <= 0 ? null : this.Url.Action("Get", null, previousFilter, Request.Scheme); result.NextPage = !String.IsNullOrWhiteSpace(nextUrl) ? new Uri(nextUrl) : null; result.PreviousPage = !String.IsNullOrWhiteSpace(previousUrl) ? new Uri(previousUrl) : null; return(result); }
public ActionResult <PagedCollectionResponse <Movie> > GetFilteredMovie([FromQuery] FilterModel filter) { if (filter != null && filter.IncludeInactive == true) { // Only Admin users are allowed to perform this action if (!IsUserAdminAutenticated()) { return(Unauthorized(new { message = "Not allowed" })); } } BLFResults <Movie> dbResult = movieTransactionScript.GetMoviesFiltered(filter); if (!dbResult.Success) { return(StatusCode(500, dbResult)); } // Get the data for the current page var result = new PagedCollectionResponse <Movie>(); result.Items = dbResult.Items; // Get next page URL string FilterModel nextFilter = filter.Clone() as FilterModel; nextFilter.Page += 1; string nextUrl = dbResult.CountNextFilter <= 0 ? null : this.Url.Action("GetFilteredMovie", null, nextFilter, Request.Scheme); // Get previous page URL string FilterModel previousFilter = filter.Clone() as FilterModel; previousFilter.Page -= 1; string previousUrl = previousFilter.Page <= 0 ? null : this.Url.Action("GetFilteredMovie", null, previousFilter, Request.Scheme); result.NextPage = !string.IsNullOrWhiteSpace(nextUrl) ? new Uri(nextUrl) : null; result.PreviousPage = !string.IsNullOrWhiteSpace(previousUrl) ? new Uri(previousUrl) : null; return(Ok(result)); }
public override void InitializeFilterModel() { var player = StorageModel.PlayerSelectedItem; var gameTypes = player != null && FilterModelManager.FilterType == EnumFilterType.Cash ? ServiceLocator.Current.GetInstance <IDataService>().GetPlayerGameTypes(player.PlayerIds) : new List <Gametypes>(); var tournaments = player != null && FilterModelManager.FilterType == EnumFilterType.Tournament ? ServiceLocator.Current.GetInstance <IDataService>().GetPlayerTournaments(player.PlayerIds) : new List <Tournaments>(); FilterModel = (FilterStandardModel)FilterModelManager.FilterModelCollection.FirstOrDefault(x => x.GetType().Equals(typeof(FilterStandardModel))); FilterModel.UpdateFilterSectionStakeLevelCollection(gameTypes); FilterModel.UpdateFilterSectionBuyinCollection(tournaments); FilterModelClone = (FilterStandardModel)FilterModel.Clone(); RaisePropertyChanged(nameof(IsStakeLevelVisible)); RaisePropertyChanged(nameof(IsBuyinVisible)); }
/// <summary> /// Get All movies filtered /// </summary> /// <returns>Result object</returns> public DBFResults <Movie> GetMoviesFiltered(FilterModel filter) { DBFResults <Movie> dbResult = new DBFResults <Movie>(); try { using (SevenDaysContext db = new SevenDaysContext(Configuration)) { // Get filtered movies and count next page dbResult.Items = FilterData(filter, filter, db).ToList(); FilterModel nextFilter = filter.Clone() as FilterModel; nextFilter.Page += 1; dbResult.CountNextFilter = FilterData(nextFilter, filter, db).Count(); dbResult.Success = true; } } catch (Exception ex) { dbResult.Message = Common.GetMessageError(ex); } return(dbResult); }
public virtual void UpdateDefaultState() { FilterModelClone = (T)FilterModel.Clone(); }
public virtual void InitializeFilterModel() { FilterModel = (T)FilterModelManager.FilterModelCollection.FirstOrDefault(x => x.GetType().Equals(typeof(T))); FilterModelClone = (T)FilterModel.Clone(); }