public ActionResult Edit(AircraftTemplate aircrafttemplate) { if (ModelState.IsValid) { context.Entry(aircrafttemplate).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } return View(aircrafttemplate); }
public ActionResult Create(AircraftTemplate aircrafttemplate) { if (ModelState.IsValid) { context.AircraftTemplates.Add(aircrafttemplate); context.SaveChanges(); return RedirectToAction("Index"); } return View(aircrafttemplate); }
// /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; }