public void Delete(int id) { using (shehryarTestingDBEntities entities = new shehryarTestingDBEntities()) { entities.usersTables.Remove(entities.usersTables.FirstOrDefault(e => e.userID == id)); entities.SaveChanges(); } }
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)); } }