public Product Delete(int id)
        {
            var removed = _ctx.Remove(new Product {
                Id = id
            }).Entity;

            _ctx.SaveChanges();
            return(removed);
        }
        public Order Delete(int id)
        {
            var removed = _ctx.Remove(new Order {
                Id = id
            }).Entity;

            _ctx.SaveChanges();
            return(removed);
        }
Example #3
0
        public Member Delete(int id)
        {
            var membRemoved = _context.Remove <Member>(new Member()
            {
                Id = id
            }).Entity;

            _context.SaveChanges();
            return(membRemoved);
        }
Example #4
0
        public FineType Delete(int id)
        {
            var fineTypeRemoved = _context.Remove(new FineType()
            {
                Id = id
            }).Entity;

            _context.SaveChangesAsync();
            return(fineTypeRemoved);
        }
Example #5
0
 public void DeleteProduct(int productid)
 {
     using (var customerContext = new CustomerAppContext())
     {
         Products product = new Products();
         product.ProductId = productid;
         customerContext.Remove(product.ProductId);
         customerContext.SaveChanges();
     }
 }
Example #6
0
        public Customer Delete(int id)
        {
            /*var ordersToRemove = _ctx.Orders.Where(o => o.Customer.Id == id);
             * _ctx.RemoveRange(ordersToRemove);*/
            var custRemoved = _ctx.Remove(new Customer {
                Id = id
            }).Entity;

            _ctx.SaveChanges();
            return(custRemoved);
        }
Example #7
0
        public Customer Delete(int id)
        {
            /*
             * //To remove all orders attached to the specific customer
             * var ordersToRemove = _ctx.Orders.Where(o => o.Customer.Id == id);
             * _ctx.RemoveRange(ordersToRemove);
             */

            //Doesn't work for customers with orders!
            //Fluint API makes it work without constraints.. Relational mapping
            var custRemoved = _ctx.Remove(new Customer {
                Id = id
            }).Entity;

            _ctx.SaveChanges();
            return(custRemoved);
        }
        public Customer Delete(int id)
        {
            //For deleting customers we can also the orders that the customers have. In a real situation,
            //we should talk with our customer as a developer about how we should clean up the data
            //sqlite informs you about deleting things with foreign keys

            //Delete Customer in this case should not delete orders

            /*var ordersToRemove = _ctx.Orders.Where(o => o.Customer.ID == id);
             * _ctx.RemoveRange(ordersToRemove);*/
            var custRemoved = _ctx.Remove <Customer>(new Customer {
                ID = id
            }).Entity;

            _ctx.SaveChanges();
            return(custRemoved);
        }