public async Task <IViewComponentResult> InvokeAsync(Guid id) { var model = new AddBarsToCocktailsViewModel(); var allBarsDto = await barService.GetAllBarsAsync(); model.Id = id; model.AllBars = allBarsDto .Select(c => new SelectListItem(c.Name, c.Name)) .ToList(); return(View(model)); }
public async Task <IActionResult> AddBars(AddBarsToCocktailsViewModel model) { if (ModelState.IsValid) { var cocktaiDto = await this.cocktailService.GetCocktailAsync(model.Id); await this.cocktailService.AddBarsAsync(cocktaiDto, model.SelectedBars); this.toastNotification.AddSuccessToastMessage("Cocktails successfuly added"); return(RedirectToAction("Details", new { id = cocktaiDto.Id })); } ModelState.AddModelError(string.Empty, ExceptionMessages.ModelError); this.toastNotification.AddWarningToastMessage("Bars were not added"); return(View(model)); }