Exemple #1
0
 public Pet Create(Pet pet)
 {
     //if(pet.PetOwner != null)
     //{
     //    pet.PetOwner = _PSActx.Owners.FirstOrDefault
     //        (o => o.OwnerId == pet.PetOwner.OwnerId);
     //}
     //var p = _PSActx.Pets.Add(pet).Entity;
     //_PSActx.SaveChanges();
     _PSActx.Attach(pet).State = EntityState.Added;
     _PSActx.SaveChanges();
     return(pet);
 }
 public Owner Update(Owner ownerUpdate)
 {
     //var oUpdate = _PSActx.Update(ownerUpdate).Entity;
     //var change = _PSActx.ChangeTracker.Entries();
     //_PSActx.Attach(oUpdate).State = EntityState.Added;
     //return oUpdate;
     _PSActx.Attach(ownerUpdate).State = EntityState.Modified;
     _PSActx.SaveChanges();
     return(ownerUpdate);
 }