Exemplo n.º 1
0
 public IEnumerable <Pet> GetAll()
 {
     //Updates data.
     for (int i = 0; i < _pets.Count; i++)
     {
         _pets[i].Colour        = _crep.GetById(_pets[i].Colour.Id);
         _pets[i].Type          = _ptrep.GetById(_pets[i].Type.Id);
         _pets[i].PreviousOwner = _prep.GetById(_pets[i].PreviousOwner.Id);
     }
     return(_pets);
 }
Exemplo n.º 2
0
        public bool PetValidation(Pet pet)
        {
            if (pet == null ||
                string.IsNullOrWhiteSpace(pet.Name) ||
                string.IsNullOrWhiteSpace(pet.Color))
            {
                return(false);
            }
            var owner = _ownerRepository.GetById(pet.OwnerId);

            if (owner == null)
            {
                throw new Exception("OwnerId failed");
            }
            if (!(pet.PreviousOwnerId is null))
            {
                var previousOwner = _ownerRepository.GetById((int)pet.PreviousOwnerId);
                if (previousOwner is null)
                {
                    throw new Exception("PreviousOwner not Exist");
                }
            }
            var petType = _petTypeRepository.GetById(pet.petTypeId);

            if (petType == null)
            {
                throw new Exception("PettypeId failed");
            }


            return(true);
        }
Exemplo n.º 3
0
 public PetType GetById(int Id)
 {
     return(_petTypeRepository.GetById(Id));
 }