Exemplo n.º 1
0
        public BeerType GetTypeById(int id)
        {
            if (id <= 0)
            {
                throw new ArgumentException("Incorrect ID entered");
            }

            return(TypeRepository.ReadTypeById(id));
        }
Exemplo n.º 2
0
        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);
        }