public async Task <IActionResult> Index() { IdentityRole nonAdminRole = new IdentityRole() { Id = Guid.NewGuid().ToString(), Name = "NotAdmin" }; IdentityRole adminRole = new IdentityRole() { Id = Guid.NewGuid().ToString(), Name = "Admin" }; await this.roleManager.CreateAsync(nonAdminRole); await this.roleManager.CreateAsync(adminRole); var model = new FlightIndexViewModel { Items = _context.Flights.Select(f => new FlightViewModel { Id = f.Id, LocationFrom = f.LocationFrom, LocationTo = f.LocationTo, FlightTakeOff = f.FlightTakeOff, FlightLanding = f.FlightLanding, PlaneModel = f.PlaneModel, PlaneId = f.PlaneId, PilotName = f.PilotName, CapacityNormal = f.CapacityNormal, CapacityBuisness = f.CapacityBuisness }).ToList() }; return(View(model)); }
public FlightIndexViewModel GetIndexView(string searchString) { var model = new FlightIndexViewModel { Flights = this.dbContext.Flights.ProjectTo <FlightViewModel>(this.mapper.ConfigurationProvider).ToList(), AirportName = searchString }; return(model); }
public IActionResult Index(string airport) { if (airport == null) { ViewData["TableType"] = "AllFlights"; } FlightIndexViewModel model = this.flightsService.GetIndexView(airport); return(View(model)); }