// // GET: /Product/Delete/5 public ActionResult Delete(int id) { tbl_product tbl_product = db.tbl_product.Single(t => t.product_id == id); string type = db.tbl_product_type.Single(ty => ty.id == tbl_product.product_type).name; ProductModel pm = new ProductModel() { product_id = tbl_product.product_id, product_name = tbl_product.product_name, create_time = tbl_product.create_time, description = tbl_product.description, pic_url = tbl_product.pic_url, product_type = type, push_level = PushLevelModel.GetPushName(tbl_product.push_level), content_url = tbl_product.content_url }; return(View(pm)); }
// // GET: /Product/ public ActionResult Index(int id = 0) { List <tbl_product> products = null; if (id == 0) { products = (from pro in db.tbl_product where pro.product_status == true select pro).ToList(); } else { products = (from pro in db.tbl_product where pro.product_type == id &&  pro.product_status == true select pro).ToList(); } List <ProductModel> p = new List <ProductModel>(); for (int i = products.Count - 1; i >= 0; i--) { tbl_product item = products[i]; string type = db.tbl_product_type.Single(name => name.id == item.product_type).name; ViewBag.types = db.tbl_product_type.ToList(); ProductModel pm = new ProductModel() { product_id = products[i].product_id, product_name = products[i].product_name, create_time = products[i].create_time, description = products[i].description, pic_url = products[i].pic_url, product_type = type, content_url = products[i].content_url, push_level = PushLevelModel.GetPushName(products[i].push_level), ticket_url = products[i].ticket_url, short_url = products[i].short_url }; p.Add(pm); } return(View(p)); }
// // GET: /Adv/Details/5 public ViewResult Details(int id) { adv_machine_product_list adv_machine_product_list = db.adv_machine_product_list.Single(a => a.id == id); tbl_product t = db.tbl_product.Single(a => a.product_id == adv_machine_product_list.product_id); string type = db.tbl_product_type.Single(name => name.id == t.product_type).name; ProductModel pm = new ProductModel { product_id = t.product_id, product_name = t.product_name, create_time = t.create_time, description = t.description, pic_url = t.pic_url, product_type = type, content_url = t.content_url, push_level = PushLevelModel.GetPushName(t.push_level), ticket_url = t.ticket_url, short_url = t.short_url }; return(View(pm)); }
public ActionResult ProductRecord(int productID) { if (productID == 0) { productID = (from item in db.tbl_product where item.product_type == 1 select item).Max(t => t.product_id); } string webUrl = ""; webUrl = Config.ConfigManager.getConfig("get-product-record-url"); webUrl += productID; WebRequest webRequest = WebRequest.Create(webUrl); HttpWebRequest request = webRequest as HttpWebRequest; request.Method = "GET"; WebResponse response = request.GetResponse(); String jsonString = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ProductRecordJsonMessage)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)); ProductRecordJsonMessage prjm = (ProductRecordJsonMessage)ser.ReadObject(ms); tbl_product product = (from item in db.tbl_product where item.product_id == productID select item).Single(); ProductModel pm = new ProductModel() { product_id = product.product_id, product_name = product.product_name, create_time = product.create_time, description = product.description, pic_url = product.pic_url, product_type = db.tbl_product_type.Single(name => name.id == product.product_type).name, content_url = product.content_url, push_level = PushLevelModel.GetPushName(product.push_level), ticket_url = product.ticket_url, short_url = product.short_url }; ViewBag.ProductModel = pm; List <Dictionary <int, string> > productList = new List <Dictionary <int, string> >(); var types = db.tbl_product_type.ToList(); foreach (tbl_product_type pt in types) { var products = (from item in db.tbl_product where item.product_type == pt.id select item).ToList(); Dictionary <int, string> pd = new Dictionary <int, string>(); foreach (tbl_product p in products) { pd.Add(p.product_id, p.product_name); } productList.Add(pd); } ViewBag.ProductList = productList; List <string> typeList = new List <string>(); foreach (var temp in types) { typeList.Add(temp.name); } ViewBag.Types = typeList; return(View(prjm)); }