public Beer CreateBeer(Beer beer) { if (beer != null) { Validator.ValidateBeer(beer); if (TypeRepository.ReadTypeById(beer.Type.ID) == null) { throw new InvalidOperationException("No type with such ID found"); } if (BrandRepository.ReadBrandById(beer.Brand.ID) == null) { throw new InvalidOperationException("No brand with such ID found"); } return(BeerRepository.AddBeer(beer)); } return(null); }
public void AddNewBeer(Beers beer) { _beerRepository.AddBeer(beer); _beerRepository.Save(); }
public IActionResult Post(Beer beer) { _beerRepository.AddBeer(beer); return(CreatedAtAction("Get", new { id = beer.Id }, beer)); }