public ActionResult Post([FromBody] AircraftModel model) { var aircraft = new Aircraft { Name = model.Name, NumberOfSeats = model.NumberOfSeats }; aircraftRepository.Add(aircraft); return(Ok()); }
public GrapherMutation(IAircraftRepository aircraftRepository) { Name = "CreateAircraftMutation"; Field <AircraftType>( "createAircraft", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <AircraftInputType> > { Name = "aircraft" } ), resolve: context => { var aircraft = context.GetArgument <Aircraft>("aircraft"); return(aircraftRepository.Add(aircraft)); }); }
public ActionResult Save(Aircraft aircraft) { //validation Form if (!ModelState.IsValid) { return(View("AircraftForm", aircraft)); } //If it is new a aircraft we save it in the data base //if its not the case, we update the aircraft if (aircraft.AircraftId == 0) { _aircraftrepository.Add(aircraft); } else { _aircraftrepository.Update(aircraft); } return(RedirectToAction("Index")); }
public void Post([FromBody] Aircraft aircraft) { _aircraftRepository.Add(aircraft); }