public async Task <IActionResult> Deleted() { var model = new AllFacilitiesViewModel { Facilities = await this.facilitiesService.GetDeletedFacilitiesAsync <FacilityListItemViewModel>(), }; return(this.View("All", model)); }
public async Task <IActionResult> All([FromQuery] string type = null) { AllFacilitiesViewModel model; if (type == null || Enum.TryParse(type, out FacilityType enumType) == false) { model = new AllFacilitiesViewModel { Facilities = await this.facilitiesService.GetAllFacilitiesAsync <FacilityListItemViewModel>(), FacilityType = "all", }; } else { model = new AllFacilitiesViewModel { Facilities = await this.facilitiesService.GetAllFacilitiesAsync <FacilityListItemViewModel>(enumType), FacilityType = type, }; } return(this.View(model)); }
public async Task <IActionResult> All(int page = 1, FacilityType?type = null) { var facilitiesCount = await this.facilitiesService.GetFacilitiesCountAsync(type); var pages = facilitiesCount / 6; if (facilitiesCount % 6 != 0 || pages == 0) { pages++; } if (page <= 0 || page > pages) { return(this.NotFound()); } if (page == 0) { page = 1; } var model = new AllFacilitiesViewModel(); if (type == null) { model.Facilities = await this.facilitiesService.GetSomeFacilitiesAsync <FacilityListItemViewModel>(page); } else { model.Facilities = await this.facilitiesService.GetSomeFacilitiesAsync <FacilityListItemViewModel>(page, 6, type); } model.Pages = pages; model.CurrentPage = page; return(this.View(model)); }