public Owner AddOwner(Owner ownerToAdd) { var changeTracker = _context.ChangeTracker.Entries <Owner>(); _context.Attach(ownerToAdd).State = EntityState.Added; _context.SaveChanges(); return(ownerToAdd); }
public Pet CreatePet(Pet pet) { if (pet.PreviousOwner != null) { _ctx.Attach(pet.PreviousOwner); } _ctx.Attach(pet).State = EntityState.Added; _ctx.SaveChanges(); return(pet); }
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); }
public Owner CreateOwner(Owner owner) { _ctx.Attach(owner).State = EntityState.Added; _ctx.SaveChanges(); return(owner); }
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); }
public PetType EditPetType(int id, PetType editedPetType) { _context.Attach(editedPetType).State = EntityState.Modified; _context.SaveChanges(); return(editedPetType); }