示例#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 Create([Bind(Include = "userid,password,zt,username,workcode,Email,phoneNumber,address,departmentid,company,login")] UserMSG userMSG)
        {
            if (ModelState.IsValid)
            {
                db.UserMSG.Add(userMSG);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userMSG));
        }
示例#3
0
 /// <summary>
 /// 增加信息
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public int Add(T t)
 {
     dBContext.Set <T>().Add(t);
     return(dBContext.SaveChanges());
 }