// GET: Port/Delete/5
        public ActionResult Delete(int id)
        {
            var model = new PortModel();
            try
            {
                var item = portUnit.PortRepository.GetByID(id);
                model = ConvertToMvcModel(item);
            }
            catch (Exception ex)
            {

                ModelState.AddModelError("",
                    $"Unable to find item to delete. ({ex.Message})");
                return RedirectToAction("Index");
            }
            return View(model);
        }
        FlightModel ConvertToMvcModel(DAL.Model.Entities.Flight item)
        {
            var flight = new FlightModel();
            flight.AirlineId = item.AirlineId;
            flight.ArrivalDate = item.ArrivalDate;
            var airline = new AirlineModel();
            using (var airlineUnit = new AirlineUnit())
            {
                var airlineItem = airlineUnit.AirlineRepository.GetByID(item.AirlineId);
                airline.Id = airlineItem.Id;
                airline.Name = airlineItem.Name;
            }
            flight.Airline = airline;
            flight.ArrivalPortId = item.ArrivalPortId;
            var arrivalPort = new PortModel();
            var departurePort = new PortModel();
            using (var portUnit = new PortUnit())
            {
                var portItem = portUnit.PortRepository.GetByID(item.Id);
                arrivalPort.Id = portItem.Id;
                arrivalPort.Name = portItem.Name;

                portItem = portUnit.PortRepository.GetByID(item.DeparturePortId);
                departurePort.Id = portItem.Id;
                departurePort.Name = portItem.Name;
            }

            flight.ArrivalPort = arrivalPort;
            flight.DepartureDate = item.DepartureDate;
            flight.DeparturePortId = item.DeparturePortId;
            flight.DeparturePort = departurePort;
            flight.FlightNumber = item.FlightNumber;
            flight.Gate = item.Gate;
            flight.Id = item.Id;
            flight.PlaceQty = item.PlaceQty;
            flight.Status = (FlightStatus)item.Status;
            flight.Terminal = item.Terminal;
            return flight;
        }
 // GET: Port/Create
 public ActionResult Create()
 {
     var model = new PortModel();
     return View(model);
 }
 static PortModel ConvertToMvcModel(Port item)
 {
     var port = new PortModel();
     port.Id = item.Id;
     port.Name = item.Name;
     return port;
 }