예제 #1
0
 public ActionResult Details(int id)
 {
     using (AdvancedWebDevelopmentEntities2 context = new AdvancedWebDevelopmentEntities2())
     {
         ProductInfo info = context.ProductInfo.Find(id);
         ViewBag.prodinfo = info;
     }
     return(View());
 }
예제 #2
0
 public ActionResult AddProductToDB(FormCollection fomr)
 {
     using (AdvancedWebDevelopmentEntities2 context = new AdvancedWebDevelopmentEntities2())
     {
         ProductInfo product = new ProductInfo();
         product.Name          = fomr["name"];
         product.Price         = Int32.Parse(fomr["price"]);
         product.Category      = fomr["categories"];
         product.Customer_ID   = Int32.Parse(Session["UserID"].ToString());
         product.Product_State = "OnSale";
         product.Description   = fomr["description"];
         context.ProductInfo.Add(product);
         context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
예제 #3
0
 public ActionResult BuyAll()
 {
     using (AdvancedWebDevelopmentEntities2 context = new AdvancedWebDevelopmentEntities2())
     {
         foreach (ProductInfo product in context.ProductInfo)
         {
             if (product.Buyer_ID == Int32.Parse(Session["UserID"].ToString()))
             {
                 if (product.Product_State == "OnCart    ")
                 {
                     context.ProductInfo.Remove(product);
                 }
             }
         }
     }
     return(RedirectToAction("Index"));
 }
예제 #4
0
        public ActionResult Index()
        {
            List <ProductInfo> products = new List <ProductInfo>();

            using (AdvancedWebDevelopmentEntities2 context = new AdvancedWebDevelopmentEntities2())
            {
                foreach (ProductInfo product in context.ProductInfo)
                {
                    var a = new ProductInfo();
                    a.ID          = product.ID;
                    a.Name        = product.Name;
                    a.Price       = product.Price;
                    a.Category    = product.Category;
                    a.Customer_ID = product.Customer_ID;
                    a.Description = product.Description;
                    products.Add(a);
                }
                ViewBag.productlist = products;
            }
            return(View());
        }