public IActionResult Get(int breweryId) { var brewery = _breweriesManager.GetBrewery(breweryId); if (brewery != null) { return(Ok(brewery)); } return(NoContent()); }
public IActionResult Post(BeerPostModel model) { var beer = (Beer)model; var brewery = _breweriesManager.GetBrewery(model.BreweryId.Value); if (brewery == null) { return(BadRequest($"Brewery with id={model.BreweryId} not found")); } _beerManager.AddBeer(beer); brewery.Beers.Add(beer); _breweriesManager.UpdateBrewery(brewery); return(NoContent()); }