Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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"));
        }