コード例 #1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
コード例 #2
0
ファイル: UserController.cs プロジェクト: cloudjun/WeBreak
        // PUT api/User/5
        public HttpResponseMessage Putwx_user(int id, wx_user wx_user)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != wx_user.ID)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }