Example #1
0
        public async Task <IActionResult> ByTown(int id)
        {
            var parkings = await this.parkingsService.GetAllByTownIdAsync(id);

            var viewModel = new ParkingsAllViewModelCollection()
            {
                Parkings = parkings.Select(p => p.To <ParkingsAllViewModel>()).ToList(),
            };

            return(this.View(viewModel));
        }
Example #2
0
        public async Task <IActionResult> All(int id = 1)
        {
            var page     = id;
            var parkings = await this.parkingsService.GetAllWithPagingAsync <ParkingsServiceAllModel>(GlobalConstants.ItemsPerPageAdmin, (page - 1) *GlobalConstants.ItemsPerPageAdmin);

            var viewModel = new ParkingsAllViewModelCollection()
            {
                Parkings = parkings.Select(p => p.To <ParkingsAllViewModel>()).ToList(),
            };

            var count = await this.parkingsService.GetCountAsync();

            viewModel.PagesCount = (int)Math.Ceiling((double)count / GlobalConstants.ItemsPerPageAdmin);

            if (viewModel.PagesCount == 0)
            {
                viewModel.PagesCount = 1;
            }

            viewModel.CurrentPage = page;

            return(this.View(viewModel));
        }