Esempio n. 1
0
        public Owner AddOwner(Owner ownerToAdd)
        {
            var changeTracker = _context.ChangeTracker.Entries <Owner>();

            _context.Attach(ownerToAdd).State = EntityState.Added;
            _context.SaveChanges();
            return(ownerToAdd);
        }
Esempio n. 2
0
 public Pet CreatePet(Pet pet)
 {
     if (pet.PreviousOwner != null)
     {
         _ctx.Attach(pet.PreviousOwner);
     }
     _ctx.Attach(pet).State = EntityState.Added;
     _ctx.SaveChanges();
     return(pet);
 }
Esempio n. 3
0
        public Pet AddPet(Pet petToAdd)
        {
            //var petTypeChangeTracker = _context.ChangeTracker.Entries<PetType>();

            //if (petToAdd.PetType != null && _context.ChangeTracker.Entries<PetType>()
            //    .FirstOrDefault(petTypeEntry => petTypeEntry.Entity.OwnerId == petToAdd.PetType.OwnerId) == null)
            //{
            //    _context.Attach(petToAdd.PetType);
            //}

            //var petOwnerChangeTracker = _context.ChangeTracker.Entries<Owner>();

            //if (petToAdd.Owner != null && _context.ChangeTracker.Entries<Owner>()
            //    .FirstOrDefault(ownerEntry =>ownerEntry.Entity.OwnerId == petToAdd.Owner.OwnerId) == null)
            //{
            //    _context.Attach(petToAdd.Owner);
            //}

            _context.Attach(petToAdd).State = EntityState.Added;
            _context.SaveChanges();
            return(petToAdd);
        }
 public User AddUser(User userToAdd)
 {
     _context.Attach(userToAdd).State = EntityState.Added;
     _context.SaveChanges();
     return(userToAdd);
 }
Esempio n. 5
0
 public Owner CreateOwner(Owner owner)
 {
     _ctx.Attach(owner).State = EntityState.Added;
     _ctx.SaveChanges();
     return(owner);
 }
Esempio n. 6
0
 public PetColor AddPetColor(PetColor petColorToAdd)
 {
     _context.Attach(petColorToAdd).State = EntityState.Added;
     _context.SaveChanges();
     return(petColorToAdd);
 }
 public Color AddColor(Color colorToAdd)
 {
     _context.Attach(colorToAdd).State = EntityState.Added;
     _context.SaveChanges();
     return(colorToAdd);
 }
Esempio n. 8
0
 public PetType EditPetType(int id, PetType editedPetType)
 {
     _context.Attach(editedPetType).State = EntityState.Modified;
     _context.SaveChanges();
     return(editedPetType);
 }