Exemple #1
0
        public Owner DeleteOwner(int id)
        {
            var ownerToRemove = _context.Owners.FirstOrDefault(o => o.id == id);

            _context.Remove(ownerToRemove);
            _context.SaveChanges();
            return(ownerToRemove);
        }
        public Owner DeleteOwner(int id)
        {
            /* _context.PetOwners.RemoveRange(
             *   _context.PetOwners.Where(po=>po.OwnerId==id));*/

            var entityRemoved = _context.Remove(new Owner {
                id = id
            }).Entity;

            _context.SaveChanges();
            return(entityRemoved);
        }
        public Pet DeletePet(int id)
        {
            var entityRemoved = _context.Remove(new Pet {
                ID = id
            }).Entity;

            _context.SaveChanges();
            return(entityRemoved);

            /*var toRemove = _context.Pets.FirstOrDefault(p => p.ID == id);
             * _context.Pets.Remove(toRemove);
             * _context.SaveChanges();
             * return toRemove*/
        }