public IHttpActionResult PutPOMASTER(string id, POMASTER pOMASTER) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pOMASTER.PONO) { return(BadRequest()); } db.Entry(pOMASTER).State = EntityState.Modified; db.Entry(pOMASTER.PODETAILs.FirstOrDefault()).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!POMASTERExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostSUPPLIER(SUPPLIER sUPPLIER) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} var d = db.SUPPLIERs.Include(X => X.POMASTERs).First(); var e = new POMASTER { PONO = "PO" + sUPPLIER.SUPLNO.Substring(2, 2), PODATE = DateTime.Now }; d.POMASTERs.Add(e); db.Entry(sUPPLIER).State = EntityState.Modified; db.SUPPLIERs.Add(sUPPLIER); try { db.SaveChanges(); } catch (DbUpdateException) { if (SUPPLIERExists(sUPPLIER.SUPLNO)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = sUPPLIER.SUPLNO }, sUPPLIER)); }
public IHttpActionResult PutSupplier(string id, Supplier supplier) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != supplier.SuplNo) { return(BadRequest()); } db.Entry(supplier).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SupplierExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutSUPPLIER(string id, SUPPLIER sUPPLIER) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sUPPLIER.SUPLNO) { return(BadRequest()); } db.Entry(sUPPLIER).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SUPPLIERExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutItem(string id, Item item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != item.itcode) { return(BadRequest()); } db.Entry(item).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutPodetail(string id, Podetail podetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != podetail.pono) { return(BadRequest()); } db.Entry(podetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PodetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutITEM(string id, ITEM iTEM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != iTEM.ITCODE) { return(BadRequest()); } db.Entry(iTEM).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ITEMExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Put([FromBody] SUPPLIER item) { using (PODbEntities db = new PODbEntities()) { db.Entry(item).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void UpdateItem(ItemModel item) { var dbItem = new ITEM { ITCODE = item.Code, ITDESC = item.Desc, ITRATE = item.Rate }; dbContext.Entry(dbItem).State = EntityState.Modified; dbContext.SaveChanges(); }
public IHttpActionResult Put(SUPPLIER obj) { db.SUPPLIERs.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; var NoOfRowsAffected = db.SaveChanges(); if (NoOfRowsAffected > 0) { return(StatusCode(HttpStatusCode.Accepted)); } else { return(BadRequest("failed to update supplier")); } }