public HttpResponseMessage PutArticles(ArticleRequest oModel) { try { using (BackNetEntity db = new BackNetEntity()) { articles oArticles = db.articles.Find(oModel.id); if (oArticles == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "La Store con el Id " + oModel.id.ToString() + " no pudo actualizarse")); } else { oArticles.name = oModel.name; oArticles.description = oModel.description; oArticles.price = oModel.price; oArticles.total_in_shelf = oModel.total_in_shelf; oArticles.total_in_vault = oModel.total_in_vault; oArticles.store_id = oModel.store_id; db.Entry(oArticles).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage PutStores(StoresRequest oModel) { try { using (BackNetEntity db = new BackNetEntity()) { stores oStore = db.stores.Find(oModel.id); if (oStore == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "La Store con el Id " + oModel.id.ToString() + " no pudo actualizarse")); } else { oStore.name = oModel.name; oStore.address = oModel.address; db.Entry(oStore).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }