public async Task <IActionResult> OnPostAsync(int?venueId, int?floorId) { if (floorId == 0) { Venues = await _venueService.GetAll(); Floors = await _floorService.GetAll(); Floors.Insert(0, new Floor()); SelectListFloors = new SelectList(Floors.FindAll(floor => floor.VenueId.Equals(venueId) || floor.VenueId == 0), nameof(Floor.FloorId), nameof(Floor.Name)); NewRoom.VenueId = (int)venueId; VenueId = (int)venueId; ModelState.Clear(); return(Page()); } NewRoom.VenueId = (int)venueId; NewRoom.FloorId = (int)floorId; if (!ModelState.IsValid) { return(RedirectToPage("Index")); } await _roomService.Create(NewRoom); return(RedirectToPage("Index")); }