예제 #1
0
        public async Task <IActionResult> ShowAllPlacesByCity(int page)
        {
            var user = await this.userManager.GetUserAsync(this.User);

            string city  = user.City;
            var    count = this.placesService.GetCountAllPlacesByCity(city);

            var viewModel = new PlaceAllViewModel();
            var places    = this.placesService.GetAllByCity <PlaceViewModel>(city, ItemsPerPage, (page - 1) * ItemsPerPage);

            if (places.Count() == 0)
            {
                return(this.RedirectToAction("NoElements", "Shared"));
            }

            foreach (var place in places)
            {
                place.PagesCount = (int)Math.Ceiling((double)count / ItemsPerPage);

                place.CurrentPage = page;
            }

            viewModel.PlacesByCity = places;

            return(this.View(viewModel));
        }
예제 #2
0
        public async Task <IActionResult> TopPlaces()
        {
            bool isAuthenticated = this.User.Identity.IsAuthenticated;
            var  viewModel       = new PlaceAllViewModel();

            if (isAuthenticated)
            {
                var user = await this.userManager.GetUserAsync(this.User);

                string city   = user.City;
                var    places = this.placesService.GetAllByCity <PlaceViewModel>(city, 5, 0);
                viewModel.PlacesByCity = places;
            }

            var allPlaces = this.placesService.GetAll <PlaceViewModel>(5, 0);

            viewModel.AllPlaces = allPlaces;
            return(this.View(viewModel));
        }
예제 #3
0
        public IActionResult ShowAllPlaces(int page)
        {
            var count = this.placesService.GetCount();

            var viewModel = new PlaceAllViewModel();
            var places    = this.placesService.GetAll <PlaceViewModel>(ItemsPerPage, (page - 1) * ItemsPerPage);

            if (places.Count() == 0)
            {
                return(this.RedirectToAction("NoElements", "Shared"));
            }

            foreach (var place in places)
            {
                place.PagesCount = (int)Math.Ceiling((double)count / ItemsPerPage);

                place.CurrentPage = page;
            }

            viewModel.AllPlaces = places;

            return(this.View(viewModel));
        }