示例#1
0
        public IHttpActionResult Putproduct_tbl(int id, product_tbl product_tbl)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != product_tbl.Id)
            {
                return(BadRequest());
            }

            db.Entry(product_tbl).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!product_tblExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
 public ActionResult Edit(introduce introduce)
 {
     if (ModelState.IsValid)
     {
         db.Entry(introduce).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(introduce));
 }
 public ActionResult Edit([Bind(Include = "id,name,img,describe,link")] news news)
 {
     if (ModelState.IsValid)
     {
         db.Entry(news).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(news));
 }
 public ActionResult Edit([Bind(Include = "id,idList,name,doc,img")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
 public ActionResult Edit([Bind(Include = "id,idList,doc")] ListPro listPro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(listPro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idList = new SelectList(db.Products, "id", "name", listPro.idList);
     return(View(listPro));
 }
示例#6
0
 public ActionResult AddSet(DBtestUser emp)
 {
     using (dataEntities db = new dataEntities())
     {
         if (emp.Id == 0)
         {
             /*
              * string fileName = Path.GetFileNameWithoutExtension(emp.Ifile.FileName);
              * string extention = Path.GetExtension(emp.Ifile.FileName);
              * fileName = fileName + DateTime.Now.ToString("yymmssff") + extention;
              * emp.UAvatar = fileName;
              * emp.Ifile.SaveAs(Path.Combine(Server.MapPath("~/AppFile/Images"), fileName));*/
             db.DBtestUsers.Add(emp);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(emp).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Update Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }