Пример #1
0
        public ActionResult InfoTourSelect(int page = 1)
        {
            int pageSize             = 5;
            var activeTours          = _managerService.GetActiveTours();
            var activeToursViewModel = MappingViewModel.MapTourListViewModel(activeTours);
            var activeToursPerPages  = activeToursViewModel.Skip((page - 1) * pageSize).Take(pageSize);
            var pageInfo             = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = activeToursViewModel.Count
            };
            var ivm = new TourPaginViewModel {
                PageInfo = pageInfo, Tours = activeToursPerPages.ToList()
            };

            return(View(ivm));
        }
Пример #2
0
        public ActionResult TourСatalog(int?sort, int?sortType, int page = 1)
        {
            var activeTours          = _customerService.GetActiveTours();
            var activeToursViewModel = MappingViewModel.MapTourListViewModel(activeTours);

            int pageSize            = 6;
            var activeToursPerPages = activeToursViewModel.Skip((page - 1) * pageSize).Take(pageSize);
            var pageInfo            = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = activeToursViewModel.Count
            };
            var ivm = new TourPaginViewModel {
                PageInfo = pageInfo, Tours = activeToursPerPages.ToList()
            };

            if (Request.HttpMethod == "POST")
            {
                if (sort != null && sortType != null)
                {
                    switch (sort.Value)
                    {
                    case 1:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.Price.CompareTo(y.Price));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.Price.CompareTo(x.Price));
                        }
                        break;
                    }

                    case 2:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.TypeOfTourId.CompareTo(y.TypeOfTourId));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.TypeOfTourId.CompareTo(x.TypeOfTourId));
                        }
                        break;
                    }

                    case 3:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.MaxNumberOfPeople.CompareTo(y.MaxNumberOfPeople));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.MaxNumberOfPeople.CompareTo(x.MaxNumberOfPeople));
                        }
                        break;
                    }

                    case 4:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.TypeOfHotel.NumberOfStars.CompareTo(y.TypeOfHotel.NumberOfStars));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.TypeOfHotel.NumberOfStars.CompareTo(x.TypeOfHotel.NumberOfStars));
                        }
                        break;
                    }

                    case 5:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.StartOfTour.CompareTo(y.StartOfTour));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.StartOfTour.CompareTo(x.StartOfTour));
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }
                return(View(ivm));
            }
            else
            {
                return(View(ivm));
            }
        }