public async Task <IActionResult> BarDetails(Guid id) { var cocktails = await this.cocktailServices.GetAllCocktails(); if (id == null) { return(NotFound()); } try { var bar = await barServices.GetBar(id); var barVM = bar.GetViewModel(); var comments = await barCommentsServices.GetAllCommentsOfBar(id); barVM.CocktailsToChoose = cocktails.Select(c => new SelectListItem(c.Name, c.Id.ToString())).ToList(); barVM.BarCocktails = await barServices.GetCocktailsForBar(id); barVM.Comments = comments.GetViewModels(); return(View(barVM)); } catch (Exception) { this.toast.AddErrorToastMessage("Something went wrong"); return(RedirectToAction(nameof(ListBars))); } }
public async Task <IActionResult> Details(Guid id) { if (id == null) { return(NotFound()); } try { var bar = await barServices.GetBar(id); var barVM = bar.GetViewModel(); return(View(barVM)); } catch (Exception) { this.toast.AddErrorToastMessage("Something went wrong"); return(RedirectToAction("ListBars", "Bar", new { Area = "" })); } }