コード例 #1
0
        public async Task <IActionResult> Edit(int id)
        {
            try
            {
                var barToEditDTO = await barServices.GetBarToEditDTOAsync(id);

                var barToEditVM = barToEditDTO.MapToViewModel();

                var cities = await cityServices.GetAllDTOAsync();

                barToEditVM.AllCities = cities.Select(c => new SelectListItem(c.Name, c.Id.ToString())).ToList();

                return(View(barToEditVM));
            }
            catch (InvalidOperationException)
            {
                return(BadRequest());
            }
        }