public ItemRepository(shopDBContext context)
 {
     _context = context;
 }
        public void rm(int customer_id)
        {
            RRDBContext        ratedb      = new RRDBContext();
            ItemvalueDBContext itemvaluedb = new ItemvalueDBContext();
            ShopItemDBContext  shopitemdb  = new ShopItemDBContext();
            ItemDBContext      itemdb      = new ItemDBContext();
            Cust_ShopDBContext custshopdb  = new Cust_ShopDBContext();
            shopDBContext      shopdb      = new shopDBContext();
            //Cs_SuDBContext cssudb = new Cs_SuDBContext();
            //CustomersDBContext customerdb = new CustomersDBContext();

            int shop_id;
            var q1 = from a1 in custshopdb.cust_shop where a1.Cust_Id == customer_id select a1;

            foreach (var item1 in q1.ToList())
            {
                shop_id = item1.S_Id;
                var       q2 = from a2 in shopitemdb.shopit where a2.S_Id == shop_id select a2;
                int       item_id;
                Shop_item si;
                foreach (var item2 in q2.ToList())
                {
                    item_id = item2.T_Id;
                    var        q3 = from a3 in itemvaluedb.item_val where item_id == a3.T_Id select a3;
                    Item_value iv;
                    foreach (var item3 in q3.ToList())
                    {
                        iv = item3;
                        itemvaluedb.item_val.Remove(iv);
                        itemvaluedb.SaveChanges();
                    }
                    si = item2;
                    shopitemdb.shopit.Remove(si);
                    shopitemdb.SaveChanges();

                    var   q4 = from a4 in itemdb.item where a4.T_Id == item_id select a4;
                    Items it;
                    foreach (var item4 in q4.ToList())
                    {
                        it = item4;
                        itemdb.item.Remove(it);
                        itemdb.SaveChanges();

                        Item_rate r = ratedb.itrat.Find(it.T_Id);
                        ratedb.itrat.Remove(r);
                        ratedb.SaveChanges();
                    }
                }
                Cust_Shop cs = item1;
                custshopdb.cust_shop.Remove(cs);
                custshopdb.SaveChanges();

                Shop s;
                var  q5 = from a5 in shopdb.shop where a5.S_Id == shop_id select a5;
                foreach (var item5 in q5.ToList())
                {
                    s = item5;
                    shopdb.shop.Remove(s);
                    shopdb.SaveChanges();
                }
            }

            var   q6 = from a6 in db5.cs_su where a6.Customer == customer_id select a6;
            Cs_Su cssu;

            foreach (var item6 in q6.ToList())
            {
                cssu = item6;
                db5.cs_su.Remove(cssu);
                db5.SaveChanges();
            }

            Customers custome = db.customer.Find(customer_id);

            db.customer.Remove(custome);
            db.SaveChanges();
        }
Example #3
0
 public OrderRepository(shopDBContext context)
 {
     _context = context;
 }