예제 #1
0
        public void AddDog(DogOwner aDogOwner, Dog aDog)
        {
            DogOwner owner = owners.FirstOrDefault(x => x.Equals(aDogOwner));

            if (owner != null)
            {
                owner.AddDog(aDog);
            }
        }
        public void AddOwner(DogOwner aDogOwner)
        {
            using (DogsDirectoryContext dbContext = new DogsDirectoryContext())
            {
                dbContext.Owners.Add(aDogOwner);

                dbContext.SaveChanges();
            }
        }
        public IEnumerable <Dog> DogsForOwner(DogOwner aDogOwner)
        {
            using (DogsDirectoryContext dbContext = new DogsDirectoryContext())
            {
                var dogs = dbContext.Dogs
                           .Where(dog => dog.Owner.Id == aDogOwner.Id)
                           .ToList();

                return(dogs);
            }
        }
        public void AddDog(DogOwner aDogOwner, Dog aDog)
        {
            using (DogsDirectoryContext dbContext = new DogsDirectoryContext())
            {
                aDog.Owner = dbContext.Owners.First(owner => owner.Id == aDogOwner.Id);

                dbContext.Dogs.Add(aDog);

                dbContext.SaveChanges();
            }
        }
예제 #5
0
 public void AddOwner(DogOwner aDogOwner)
 {
     owners.Add(aDogOwner);
 }