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

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "userid,password,zt,username,workcode,Email,phoneNumber,address,departmentid,company,login")] UserMSG userMSG)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userMSG).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userMSG));
 }
示例#3
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public int Update(T t)
 {
     dBContext.Entry(t).State = EntityState.Modified;
     return(dBContext.SaveChanges());
 }