Пример #1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
Пример #2
0
        // 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));
        }