Ejemplo n.º 1
0
        public Pet CreateNewPetServ(Pet newPet)
        {
            DateTime dateReference = new DateTime();

            if (string.IsNullOrEmpty(newPet.name))
            {
                throw new Exception("Please enter a name for the pet");
            }
            if (string.IsNullOrEmpty(newPet.type))
            {
                throw new Exception("Please assign the type of pet");
            }
            if (newPet.birthdate != dateReference && newPet.soldDate != dateReference)
            {
                if (DateTime.Compare(newPet.soldDate, newPet.birthdate) < 0)
                {
                    throw new Exception("Can not create a pet whose sold date is before its birthdate");
                }
            }
            return(_petRepo.CreateNewPetRepo(newPet));
        }