Example #1
0
 public ActionResult Create([Bind(Include = "Id,prod_name,prod_des,prod_sbid,prod_cbid,prod_pic")] Item_table item_table, HttpPostedFileBase file)
 {
     if (ModelState.IsValid)
     {
         string path = "";
         if (file != null && file.ContentLength > 0)
         {
             try
             {
                 path = "\\Images\\" + Path.GetFileName(file.FileName);
                 file.SaveAs(path);
                 ViewBag.Message = "File uploaded successfully";
             }
             catch (Exception ex)
             {
                 ViewBag.Message = "ERROR:" + ex.Message.ToString();
             }
         }
         else
         {
             ViewBag.Message = "You have not specified a file.";
         }
         item_table.prod_pic = path;
         db.Item_table.Add(item_table);
         db.SaveChanges();
         return(RedirectToAction("Index", "Item_table"));
     }
     return(View(item_table));
 }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Item_table item_table = db.Item_table.Find(id);

            db.Item_table.Remove(item_table);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
        // GET: Item_table/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Item_table item_table = db.Item_table.Find(id);

            if (item_table == null)
            {
                return(HttpNotFound());
            }
            return(View(item_table));
        }
Example #4
0
 public ActionResult Auction([Bind(Include = "Id,prod_name,prod_des,prod_sbid,prod_cbid")] Item_table item_table)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(item_table).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Auction"));
         }
         return(View(item_table));
     }
     catch (DbEntityValidationException e)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.)
         ModelState.AddModelError("", e.ToString() + "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
         return(View());
     }
 }