public async Task <IActionResult> Create() { var countries = await this.countriesService.GetAllAsync <CountriesServiceDropDownModel>(); var viewModel = new TownInputModel(); viewModel.Countries = countries.Select(c => c.To <CountriesDropDownViewModel>()).ToList(); return(this.View(viewModel)); }
public async Task <IActionResult> Create(TownInputModel townInputModel) { if (!this.ModelState.IsValid) { return(this.View(townInputModel)); } var townServiceModel = townInputModel.To <TownServiceInputModel>(); await this.townsService.CreateAsync(townServiceModel); return(this.Redirect("/Administration/Towns/All")); }