Example #1
0
        public Animal BuyAnimal <T>(Person person)
        {
            if (_shelterRepository.IsShelterEmpty())
            {
                return(null);
            }

            //throw an exception if invalid kind of animal
            if (!d.ContainsValue(typeof(T)))
            {
                throw new ArgumentException($"Expected {string.Join(", ", d.Keys.ToList())}" +
                                            $" received {typeof(T).Name.ToLower()}");
            }
            var type = d.FirstOrDefault(x => x.Value == typeof(T)).Value;

            return(_purchaseHelper.PurchaseAnimal <T>(person));
        }