public ActionResult Edit(int id) { var flight = Mapper.Map <FlightViewModel>(_flightService.GetById(id)); SetAirPortPlaneListInFlights(flight); return(View(flight)); }
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)); }