Ejemplo n.º 1
0
        public ActionResult FilterGames(FilterCriteriaViewModel filterViewModel, string size, int page = 1)
        {
            PaginationGames games;

            if (ModelState.IsValid)
            {
                FilterCriteria filters = _mapper.Map <FilterCriteriaViewModel, FilterCriteria>(filterViewModel);
                games             = _gameService.FilterGames(filters, page, size, CurrentLanguageCode);
                TempData["games"] = games;
            }
            else
            {
                games             = TempData["games"] as PaginationGames;
                TempData["games"] = games;
            }

            filterViewModel.Genres        = _mapper.Map <IEnumerable <Genre>, IList <GenreViewModel> >(_genreService.GetAllGenresAndMarkSelectedForFilter(filterViewModel.NameGenres, CurrentLanguageCode));
            filterViewModel.PlatformTypes = _mapper.Map <IEnumerable <PlatformType>, IList <PlatformTypeViewModel> >(_platformTypeService.GetAllPlatformTypesAndMarkSelected(filterViewModel.NamePlatformTypes, CurrentLanguageCode));
            filterViewModel.Publishers    = _mapper.Map <IEnumerable <Publisher>, IList <PublisherViewModel> >(_publisherService.GetAllPublishersAndMarkSelected(filterViewModel.NamePublishers, CurrentLanguageCode));

            var pageInfo = new PagingInfoViewModel()
            {
                CurrentPage  = page,
                ItemsPerPage = size,
                TotalItems   = games.Count
            };

            return(View("games", new GamesAndFilterViewModel()
            {
                Filter = filterViewModel, Games = _mapper.Map <IEnumerable <Game>, IList <GameViewModel> >(games.Games), PagingInfo = pageInfo
            }));
        }
        //[ActionName("GetFilterCriteriaByCategory")]
        public HttpResponseMessage GetFilterCriteriaByCategory(int Id)
        {
            List <FilterCriteria> lstFilterCriteria = _db.FilterCriterias.Where(o => o.CategoryId == Id).ToList();

            FilterCriteriaResponse _FilterCriteriaResponse = new FilterCriteriaResponse();

            _FilterCriteriaResponse.MESSAGE = "Filter Criteria By Category";
            _FilterCriteriaResponse.Flag    = "false";
            if (lstFilterCriteria != null)
            {
                List <FilterCriteriaViewModel> lstCriteria = new List <FilterCriteriaViewModel>();
                _FilterCriteriaResponse.Flag = "true";

                for (int i = 0; i < lstFilterCriteria.Count(); i++)
                {
                    FilterCriteriaViewModel _FilterCriteriaViewModel = new FilterCriteriaViewModel();
                    _FilterCriteriaViewModel.CategoryId       = lstFilterCriteria[i].CategoryId;
                    _FilterCriteriaViewModel.FilterCriteriaId = lstFilterCriteria[i].FilterCriteriaId;
                    _FilterCriteriaViewModel.CriteriaText     = lstFilterCriteria[i].CriteriaText;

                    lstCriteria.Add(_FilterCriteriaViewModel);
                }
                _FilterCriteriaResponse.Criteria = lstCriteria;

                return(Request.CreateResponse(HttpStatusCode.OK, _FilterCriteriaResponse));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, lstFilterCriteria));
        }
Ejemplo n.º 3
0
        public IHttpActionResult FilterGames(string contentType, FilterCriteriaViewModel filterViewModel, string size, int page = 1)
        {
            if (!ModelState.IsValid)
            {
                return(Content(HttpStatusCode.BadRequest, CreateError()));
            }
            FilterCriteria  filters = _mapper.Map <FilterCriteriaViewModel, FilterCriteria>(filterViewModel);
            PaginationGames games   = _gameService.FilterGames(filters, page, size, CurrentLanguage);

            filterViewModel.Genres        = _mapper.Map <IEnumerable <Genre>, IList <GenreViewModel> >(_genreService.GetAllGenresAndMarkSelectedForFilter(filterViewModel.NameGenres, CurrentLanguage));
            filterViewModel.PlatformTypes = _mapper.Map <IEnumerable <PlatformType>, IList <PlatformTypeViewModel> >(_platformTypeService.GetAllPlatformTypesAndMarkSelected(filterViewModel.NamePlatformTypes, CurrentLanguage));
            filterViewModel.Publishers    = _mapper.Map <IEnumerable <Publisher>, IList <PublisherViewModel> >(_publisherService.GetAllPublishersAndMarkSelected(filterViewModel.NamePublishers, CurrentLanguage));

            var pageInfo = new PagingInfoViewModel
            {
                CurrentPage  = page,
                ItemsPerPage = size,
                TotalItems   = games.Count
            };

            var result = Serialize(new GamesAndFilterViewModel()
            {
                Filter     = filterViewModel,
                Games      = _mapper.Map <IEnumerable <Game>, IList <GameViewModel> >(games.Games),
                PagingInfo = pageInfo
            },
                                   contentType);

            return(result);
        }
Ejemplo n.º 4
0
 public static FilterCriteria Create(FilterCriteriaViewModel filterCriteriaViewModel)
 {
     return(new FilterCriteria
     {
         Name = filterCriteriaViewModel.Name,
         Value = filterCriteriaViewModel.Value
     });
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> GetRequests([FromBody] FilterCriteriaViewModel filter)
        {
            var requests = await _service.FilterAsync(filter);

            if (requests.Count == 0)
            {
                requests = new List <DashboardViewModel>();
            }

            return(Ok(requests));
        }
Ejemplo n.º 6
0
        public HttpResponseMessage GetAllCategories()
        {
            CategoryResponse objresponse = new CategoryResponse();

            var lstCategories = _db.Categories.Select(o => new { o.CategoryId, o.Category1 }).ToList();

            objresponse.MESSAGE = "All Categories";
            objresponse.Flag    = "false";

            if (lstCategories != null)
            {
                List <CategoryViewModel> lstCategoryViewModel = new List <CategoryViewModel>();
                objresponse.Flag = "true";
                for (int i = 0; i < lstCategories.Count(); i++)
                {
                    CategoryViewModel _CategoryViewModel = new CategoryViewModel();
                    _CategoryViewModel.CategoryName = lstCategories[i].Category1;
                    _CategoryViewModel.CategoryId   = lstCategories[i].CategoryId;

                    _CategoryViewModel.FilterCriterias = new List <FilterCriteriaViewModel>();
                    var categoryFilterCriterias = _db.FilterCriterias.Where(fc => fc.CategoryId == _CategoryViewModel.CategoryId).ToList();

                    FilterCriteriaViewModel _DefaultFilterCriteria = new FilterCriteriaViewModel();
                    _DefaultFilterCriteria.FilterCriteriaId = 0;
                    _DefaultFilterCriteria.CategoryId       = _CategoryViewModel.CategoryId;
                    _DefaultFilterCriteria.CriteriaText     = "All";
                    _CategoryViewModel.FilterCriterias.Add(_DefaultFilterCriteria);

                    if (null != categoryFilterCriterias)
                    {
                        foreach (var fc in categoryFilterCriterias)
                        {
                            FilterCriteriaViewModel _FilterCriteriaViewModel = new FilterCriteriaViewModel();
                            _FilterCriteriaViewModel.FilterCriteriaId = fc.FilterCriteriaId;
                            _FilterCriteriaViewModel.CategoryId       = fc.CategoryId;
                            _FilterCriteriaViewModel.CriteriaText     = fc.CriteriaText;
                            _CategoryViewModel.FilterCriterias.Add(_FilterCriteriaViewModel);
                        }
                    }
                    lstCategoryViewModel.Add(_CategoryViewModel);
                }
                objresponse.Categories = lstCategoryViewModel;
                return(Request.CreateResponse(HttpStatusCode.OK, objresponse));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, objresponse));
            }
        }
Ejemplo n.º 7
0
        public async Task <List <DashboardViewModel> > FilterAsync(FilterCriteriaViewModel criteria)
        {
            var dashboardContainer = new List <DashboardViewModel>();
            var requests           = await this.requestRepo.GetPagedListAsync(
                include : r => r.Include(rr => rr.NewAffiliation)
                .ThenInclude(n => n.CustomerProfile)
                .Include(rr => rr.NewAffiliation.Branches),
                orderBy : x => x.OrderByDescending(y => y.Id),
                predicate : r => criteria.status != 0?r.Status == criteria.status : true &&
                criteria.trackingNo != null?r.TrackingNo == criteria.trackingNo : true &&
                criteria.createdDate != null?r.CreatedDate == criteria.createdDate : true &&
                criteria.legalName != null?r.NewAffiliation.CustomerProfile.legalName.ToLower().Contains(criteria.legalName.ToLower()) : true &&
                criteria.requestType != 0?r.RequestType == criteria.requestType : true);

            IList <Request> reqList = new List <Request>();

            if (criteria.dbaName != null)
            {
                foreach (var item in requests.Items)
                {
                    bool isAdded = false;
                    foreach (var branch in item.NewAffiliation.Branches)
                    {
                        {
                            if (branch.dbaName.ToLower().Contains(criteria.dbaName.ToLower()))
                            {
                                isAdded = true;
                                break;
                            }
                        }
                    }

                    if (isAdded)
                    {
                        reqList.Add(item);
                    }
                }
            }
            else
            {
                reqList = requests.Items;
            }


            foreach (var item in reqList)
            {
                dashboardContainer.Add(new DashboardViewModel
                {
                    RequestId     = item.Id,
                    requestedDate = item.CreatedDate.Value,
                    businessName  = item.NewAffiliation.CustomerProfile.legalName,
                    referenceNo   = item.TrackingNo,
                    requestedBy   = item.CreatedBy,
                    requestType   = "NEW AFFILIATION",
                    status        = statusService.GetStatus(item.Status),
                    tat           = (int)(DateTime.Now - item.CreatedDate.Value).TotalHours
                });
            }

            return(dashboardContainer);
        }
Ejemplo n.º 8
0
 public static FilterCriteria FromViewModel(this FilterCriteriaViewModel filterCriteria)
 {
     return(DataModelFactory.Create(filterCriteria));
 }