Exemplo n.º 1
0
        public ActionResult Details(string id)
        {
            var brewery = new BreweryViewModel()
            {
                Brewery = _breweryOrchestrator.GetById(id),
                Beers   = _beerOrchestrator.GetByBrewery(id)
            };

            return(View("Details", brewery));
        }
Exemplo n.º 2
0
        public ActionResult Create(CreateBeerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var existing = _beerOrchestrator.GetByBrewery(model.BreweryId);

            if (existing.Any(b => b.Name == model.Name))
            {
                ModelState.AddModelError("BeerName", "A beer with that name already exists for this brewery.");
                return(View(model));
            }

            string id = _beerOrchestrator.CreateBeer(model.Name, model.ABV, model.BAScore, model.StyleId, model.BreweryId);

            return(RedirectToAction("Details", "Beer", new { id = id }));
        }