samedi 29 février 2020

Why is some sql tables not updated by PUT api requests

I use this code to update table "BI_table", it works fine. If use the same code(but changed table "machines"), it will not update. The controller and class is also the same. My suspicion is, that BI_table has no relations to other tables in my database but machines has. How to update machines table?


[HttpPut]
         public HttpResponseMessage Put(int id,[FromBody]BI_table value) 
        {
            using (testdatabseEntities1 nd = new testdatabseEntities1())
            {
                 var entities = nd.BI_table.FirstOrDefault(e => e.id == id);

                if (entities == null)
                {
                    return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Id findes ikke..");
                }

                else
                {

                    entities.id = value.id;
                    entities.stopcause = value.stopcause;
                    nd.SaveChanges();
                    return Request.CreateResponse(HttpStatusCode.OK, entities);

                }
            }
        }




Aucun commentaire:

Enregistrer un commentaire