public Pet UpdatePet(Pet pet) { _ctx.Attach(pet).State = EntityState.Modified; //_ctx.Entry(pet).Reference(p => p.Owner).IsModified = true; _ctx.SaveChanges(); return(pet); }
public Owner UpdateOwner(Owner owner) { _ctx.Attach(owner).State = EntityState.Modified; //_ctx.Entry(owner).Reference(c => c.OwnedPets).IsModified = true; _ctx.SaveChanges(); return(owner); }
public Customer CreateCustomer(Customer customer) { if (customer.Orders != null) { _ctx.Attach(customer.Orders); } var _customer = _ctx.Customers.Add(customer).Entity; _ctx.SaveChanges(); return(_customer); }
public Order CreateOrder(Order order) { if (order.Customer != null) { _ctx.Attach(order.Customer); } var newOrder = _ctx.Orders.Add(order).Entity; _ctx.SaveChanges(); return(newOrder); }
public Owner Update(Owner ownerUpdate) { _ctx.Attach(ownerUpdate).State = EntityState.Modified; _ctx.SaveChanges(); return(ownerUpdate); }
public Owner CreateOwner(Owner owner) { Owner ownerToReturn = _context.Attach(owner).Entity; _context.SaveChanges(); return(ownerToReturn); }
public void CreatePet(Pet pet) { //_context.pets.Add(pet); //_context.SaveChanges(); _context.Attach(pet).State = EntityState.Added; _context.SaveChanges(); }
public Pet Add(Pet pet) { Pet item; try { var entityEntry = _ctx.Attach(pet); entityEntry.State = EntityState.Added; item = entityEntry.Entity; _ctx.SaveChanges(); } catch (Exception e) { throw new RepositoryException("Error adding pet: " + e.Message, e); } return(item); }
public Pet CreatePet(Pet pet) { _ctx.Attach(pet).State = EntityState.Added; _ctx.SaveChanges(); return(pet); /*var newPet = _ctx.Add(pet); * _ctx.SaveChanges(); * return newPet.Entity;*/ }
public void CreateOwner(Owner owner) { _context.Attach(owner).State = EntityState.Added; }
public Owner Update(int id, Owner owner) { context.Attach(owner).State = EntityState.Modified; return(owner); }
public Pet CreatePet(Pet pet) { Pet petToReturn = _context.Attach(pet).Entity; _context.SaveChanges(); return petToReturn; }
public Pet CreatePet(Pet newPet) { _context.Attach(newPet).State = EntityState.Added; _context.SaveChanges(); return(newPet); }
public Owner Create(Owner owner) { _Context.Attach(owner).State = EntityState.Added; _Context.SaveChanges(); return(owner); }
public Pet Update(int id, Pet pet) { context.Attach(pet).State = EntityState.Modified; context.SaveChanges(); return(pet); }