public ActionResult DeleteConfirmed(int id) { Item_rate item_rate = db.itrat.Find(id); db.itrat.Remove(item_rate); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /item_rated/Delete/5 public ActionResult Delete(int id = 0) { Item_rate item_rate = db.itrat.Find(id); if (item_rate == null) { return(HttpNotFound()); } return(View(item_rate)); }
public ActionResult Edit(Item_rate item_rate) { if (ModelState.IsValid) { db.Entry(item_rate).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item_rate)); }
public ActionResult Create(Item_rate item_rate) { if (ModelState.IsValid) { db.itrat.Add(item_rate); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item_rate)); }
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(); }
public ActionResult MostRated_Product() { List <Itemadder> itmAdr_lst = new List <Itemadder>(); List <Items> itm_lst = new List <Items>(); //--------------- List <Categories> cat_lst = (from a in dbcat.category select a).ToList(); List <Items> it_lst = (from a in dbitem.item select a).ToList(); if (it_lst.Count != 0) { foreach (var i in cat_lst) { var reslt = (from t in dbitem.item where t.Cat_Id == i.Cat_Id select t.T_Id).ToList(); if (reslt != null && reslt.Count != 0) { var itms_dd = from t in dbitem.item where t.Cat_Id == i.Cat_Id select t.T_Id; int maxRate = int.MinValue; int maxRate_itmID = 0; bool isAnyRated = false; int id_lst_itm = 0; foreach (var id in itms_dd) { var iteeasd = from a in ratdb.itrat where id == a.Id select a; if (iteeasd != null && iteeasd.ToList().Count != 0) { Item_rate itrt = (from a in ratdb.itrat where id == a.Id select a).First(); int r = itrt.Up - itrt.Down; if (maxRate < r) { maxRate = r; maxRate_itmID = id; } isAnyRated = true; } id_lst_itm = id; } if (!isAnyRated) { maxRate_itmID = id_lst_itm; } //-----------make itm Items it = new Items(); it.Cat_Id = i.Cat_Id; if (maxRate_itmID != null && maxRate_itmID != 0) { it.T_Id = maxRate_itmID; it.T_Name = (from a in dbitem.item where maxRate_itmID == a.T_Id select a.T_Name).First(); itm_lst.Add(it); //-----------make prop ItemController asd = new ItemController(); Itemadder itmAd = asd.add_prop_item(it); var g = from a in ratdb.itrat where a.Id == itmAd.item_id select a; foreach (var b in g) { itmAd.up = b.Up; itmAd.down = b.Down; } int shop_id = (from a in shopit.shopit where a.T_Id == itmAd.item_id select a.S_Id).First(); itmAd.shop_name = (from a in shopdb.shop where a.S_Id == shop_id select a.About).First(); itmAd.shop_id = shop_id; //itmAd.time_added = itmAdr_lst.Add(itmAd); } } } } ViewBag.MostRated_Product_Got = itmAdr_lst; return(View()); }