public IActionResult Index() { if (User.IsInRole("Admin") == false) { return(RedirectToAction("Index", "Home")); } var flightModels = _flights.GetAll().OrderByDescending(flight => flight.Departure); var listingResult = flightModels .Select(result => new FlightListingModel { Id = result.Id, Origin = _flights.GetOrigin(result.Id), Destination = _flights.GetDestination(result.Id), Departure = _flights.GetDeparture(result.Id).ToString(), Duration = _flights.GetDuration(result.Id), Arrival = _flights.GetDeparture(result.Id).AddSeconds(_flights.GetDuration(result.Id) * Config.Scale).ToString(), Plane = _flights.GetById(result.Id).Plane.Model, Status = _flights.GetStatus(result.Id) }); var model = new FlightIndexModel() { Flights = listingResult }; return(View(model)); }
public ActionResult index() { var flights = Mapper.Map <List <FlightViewModel> >(_flightService.GetAll()); SetAirPortPlaneNamesInFlights(flights); return(View(flights)); }
public IActionResult GetAllFlights() { _log4net.Info(" Http GeAllDetails request Initiated"); try { var list = repo.GetAll(); if (list != null) { return(Ok(list)); } return(BadRequest("No Data yet")); } catch (Exception) { return(BadRequest("Some Error Occured Please try again")); } }