示例#1
0
        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);
        }
示例#2
0
 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);
 }
示例#3
0
 public PetEntity Update(PetEntity petUpdate)
 {
     _PActx.Attach(petUpdate).State = EntityState.Modified;
     _PActx.Entry(petUpdate).Reference(p => p.Owner).IsModified = true;
     _PActx.SaveChanges();
     return(petUpdate);
 }
示例#4
0
 public User CreateUser(User user)
 {
     _context.Attach(user).State = EntityState.Added;
     _context.SaveChanges();
     return(user);
 }
示例#5
0
 public Pet CreatePet(Pet pet)
 {
     _context.Attach(pet).State = EntityState.Added;
     _context.SaveChanges();
     return(pet);
 }
示例#6
0
 public Owner Create(Owner owner)
 {
     _ctx.Attach(owner).State = EntityState.Added;
     _ctx.SaveChanges();
     return(owner);
 }
示例#7
0
 public Owner CreateOwner(Owner owner)
 {
     _context.Attach(owner).State = EntityState.Added;
     _context.SaveChanges();
     return(owner);
 }