Exemplo n.º 1
0
 public Pet UpdatePet(Pet pet)
 {
     _ctx.Attach(pet).State = EntityState.Modified;
     //_ctx.Entry(pet).Reference(p => p.Owner).IsModified = true;
     _ctx.SaveChanges();
     return(pet);
 }
Exemplo n.º 2
0
 public Owner UpdateOwner(Owner owner)
 {
     _ctx.Attach(owner).State = EntityState.Modified;
     //_ctx.Entry(owner).Reference(c => c.OwnedPets).IsModified = true;
     _ctx.SaveChanges();
     return(owner);
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
 }
Exemplo n.º 12
0
 public Pet CreatePet(Pet pet)
 {
     Pet petToReturn = _context.Attach(pet).Entity;
     _context.SaveChanges();
     return petToReturn;
 }
Exemplo n.º 13
0
 public Pet CreatePet(Pet newPet)
 {
     _context.Attach(newPet).State = EntityState.Added;
     _context.SaveChanges();
     return(newPet);
 }
Exemplo n.º 14
0
 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);
 }