public Pet Create(Pet pet) { var changeTracker = _context.ChangeTracker.Entries <Owner>(); if (pet.Owners != null && _context.ChangeTracker.Entries <Owner>() .FirstOrDefault(pe => pe.Entity.Id == pet.Owner.Id) == null) { _context.Attach(pet.Owners); } var own = _context.Pets.Add(pet).Entity; _context.SaveChanges(); return(pet); }
public Pet Create(Pet pet) { /*/ if (pet.PreviousOwner!=null && _ptx.ChangeTracker.Entries<Owner>().FirstOrDefault(ow=> ow.Entity.id == pet.PreviousOwner.id ) == null) * { * _ptx.Attach(pet.PreviousOwner); * } * var animal = _ptx.Pets.Add(pet).Entity; * _ptx.SaveChanges(); * return animal; * /*/ _ptx.Attach(pet).State = EntityState.Added; _ptx.SaveChanges(); return(pet); }
public PetEntity Update(PetEntity petUpdate) { _PActx.Attach(petUpdate).State = EntityState.Modified; _PActx.Entry(petUpdate).Reference(p => p.Owner).IsModified = true; _PActx.SaveChanges(); return(petUpdate); }
public User CreateUser(User user) { _context.Attach(user).State = EntityState.Added; _context.SaveChanges(); return(user); }
public Pet CreatePet(Pet pet) { _context.Attach(pet).State = EntityState.Added; _context.SaveChanges(); return(pet); }
public Owner Create(Owner owner) { _ctx.Attach(owner).State = EntityState.Added; _ctx.SaveChanges(); return(owner); }
public Owner CreateOwner(Owner owner) { _context.Attach(owner).State = EntityState.Added; _context.SaveChanges(); return(owner); }