public async Task CreateAirportAsync(AirportCreateInputModel model) { var airport = this.mapper.Map <Airport>(model); this.dbContext.Airports.Add(airport); await this.dbContext.SaveChangesAsync(); }
public async Task <IActionResult> Create() { var model = new AirportCreateInputModel(); model.Cities = await this.citiesService.GetAllCitiesAsDropdownListAsync(); return(View(model)); }
public async Task <AirportCreateInputModel> GetAirportCreateInputModelAsync() { var model = new AirportCreateInputModel(); model.Cities = await this.citiesService.GetAllCitiesAsDropdownListAsync(); return(model); }
public async Task <IActionResult> Create(AirportCreateInputModel model) { bool isAirportExists = await this.airportsService.IsAirportExistsAsync(model.IcaoCode); if (isAirportExists) { this.ModelState.AddModelError("IcaoCode", "Provided ICAO Code already exists"); } if (!this.ModelState.IsValid) { model.Cities = await this.citiesService.GetAllCitiesAsDropdownListAsync(); return(this.View(model)); } await this.airportsService.CreateAirportAsync(model); return(RedirectToAction("Index")); }