Ejemplo n.º 1
0
        public void Add(Flight NewFlight)
        {
            NewFlight.Plane    = _planes.GetById(NewFlight.PlaneId);
            NewFlight.Duration = FindFlightDuration(NewFlight.Origin, NewFlight.Destination) / Config.Scale;

            _context.Add(NewFlight);
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        // UPDATE
        public IActionResult Edit(int id)
        {
            if (User.IsInRole("Admin") == false)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var planeModel = _planes.GetById(id);

            var formData = new PlaneFormModel
            {
                Id           = id,
                MaxCapacity  = planeModel.MaxCapacity,
                Identifier   = planeModel.Identifier,
                Type         = planeModel.Type,
                Manufacturer = planeModel.Manufacturer,
                Model        = planeModel.Model,
                Year         = planeModel.Year,
                FlyingHours  = planeModel.FlyingHours
            };

            return(View(formData));
        }