public ActionResult AirportCreate([Bind(Include = "Id,Name,Code,CityId")] AirportViewModel airport) { if (ModelState.IsValid) { airport.City = _cityService.GetCity(airport.CityId); _airportService.CreateAirport(Mapper.Map <AirportViewModel, Airport>(airport)); return(RedirectToAction("AirportIndexFull")); } airport.Cities = _cityService.GetCities(); return(View(airport)); }
public IActionResult CreateAirport([FromBody] AirportFormCreate newAirportForm) { if (newAirportForm == null) { return(BadRequest()); } Airport newCreatedAirport = _airportService.CreateAirport(newAirportForm); return(CreatedAtRoute( routeName: nameof(GetAirportById), routeValues: new { airportId = newCreatedAirport.Id }, value: CreateLinks(newCreatedAirport))); }
public IActionResult CreateContactPost(string name, string city, bool isInternational) { var newAirport = new Airport() { Name = name, City = city, IsInternational = isInternational }; _airportService.CreateAirport(newAirport); var airportList = _airportService.GetAllAirports(); return(View("Airport", airportList)); }