Ejemplo n.º 1
0
        public async Task <IActionResult> AddBuilding(SelectedBuildingViewModel selectedBuildingViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _countryService.AddBuildingAsync(selectedBuildingViewModel.Id, selectedBuildingViewModel.BuildingId);

                    return(RedirectToAction("Details", new { @id = selectedBuildingViewModel.Id }));
                }
                catch (GameException e)
                {
                    ModelState.AddModelError(e.Key, e.Description);
                }
            }
            selectedBuildingViewModel.Buildings = await _countryService.ListBuildingsAsync();

            return(View(selectedBuildingViewModel));
        }