コード例 #1
0
        public async Task <IActionResult> EditCocktails(int id)
        {
            try
            {
                var barVM = new EditCocktailsViewModel();
                var dto   = await barServices.GetBasicDTOAsync(id);

                barVM.BarName   = dto.Name;
                barVM.ImagePath = dto.ImagePath;

                barVM.PresentCocktails = (await barServices.GetPresentCocktailsAsync(id))
                                         .Select(c => new SelectListItem(c.Name, c.Id.ToString()));

                barVM.NotPresentCocktails = (await barServices.NotPresentCocktailsAsync(id))
                                            .Select(c => new SelectListItem(c.Name, c.Id.ToString()));

                return(View(barVM));
            }
            catch (InvalidCastException)
            {
                return(BadRequest());
            }
        }