コード例 #1
0
 public ActionResult Edit(AircraftModel aircraftmodel)
 {
     if (ModelState.IsValid)
     {
         _context.Entry(aircraftmodel).State = EntityState.Modified;
         _context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(aircraftmodel);
 }
コード例 #2
0
        public ActionResult Create(AircraftModel aircraftmodel)
        {
            if (ModelState.IsValid)
            {
                _context.AircraftModels.Add(aircraftmodel);
                _context.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(aircraftmodel);
        }
コード例 #3
0
 //
 // GET: /Aircraft/Create
 public ActionResult Create()
 {
     var templates = _context.AircraftTemplates.Select(x => new SelectListItem {Text = x.Airframe, Value = x.Id.ToString()});
     var aircraftModel = new AircraftModel {AircraftTemplates = templates};
     return View(aircraftModel);
 }
コード例 #4
0
 // /Aircraft/CreateFrom/5
 //        [HttpPost]
 //        public ActionResult CreateFrom(AircraftModel model)
 //        {
 //
 //            var aircraftTemplate = _context.AircraftTemplates.Single(x => x.Id == aircraftTemplateId);
 //            var aircraftModel = AdaptAircraft(aircraftTemplate);
 //            return Create(aircraftModel);
 //
 //
 //        }
 AircraftModel AdaptAircraft(AircraftTemplate t)
 {
     var result = new AircraftModel
         {
             Airframe = t.Airframe,
             BasicOpWeight = t.BasicOpWeight,
             CargoHoldCount = t.CargoHoldCount,
             EmptyWeight = t.EmptyWeight,
             EmptyWeightCg = t.EmptyWeightCg,
             EmptyWeightMoment = t.EmptyWeightMoment,
             EngineCount = t.EngineCount,
             FuelTankCount = t.FuelTankCount,
             MaxFuelCapacity = t.MaxFuelCapacity,
             SeatCount = t.SeatCount,
             MaxZeroFuelWeight = t.MaxZeroFuelWeight,
             MaxLandingWeight = t.MaxLandingWeight,
             MaxOpWeight = t.MaxOpWeight,
             MaxRampWeight = t.MaxRampWeight,
             MaxTakeoffWeight = t.MaxTakeoffWeight,
         };
     return result;
 }