コード例 #1
0
 public void Delete(int id)
 {
     using (shehryarTestingDBEntities entities = new shehryarTestingDBEntities())
     {
         entities.usersTables.Remove(entities.usersTables.FirstOrDefault(e => e.userID == id));
         entities.SaveChanges();
     }
 }
コード例 #2
0
 public HttpResponseMessage PUT([FromBody] usersTable users)
 {
     try
     {
         using (shehryarTestingDBEntities entities = new shehryarTestingDBEntities())
         {
             entities.usersTables.Add(users);
             entities.SaveChanges();
             var message = Request.CreateResponse(HttpStatusCode.Created, users);
             message.Headers.Location = new Uri(Request.RequestUri + users.userID.ToString());
             return(message);
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }