public IHttpActionResult Putcustomer(int id, customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.customerId) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!customerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
static void UpdateNextProcess(ProductProcess ProductProcess, int Accepted, WebApplication5Context db) { ProductProcess NextProductProcess = db.ProductProcesses.FirstOrDefault(q => q.Product.Code == ProductProcess.Product.Code && q.Order == ProductProcess.Order + 1); if (NextProductProcess != null) { //gets the next productprocess Wip nextw = db.Wips.FirstOrDefault <Wip>(e => e.ProductProcess.ID == NextProductProcess.ID); if (nextw == null) { nextw = new Wip(); nextw.ProductProcess = NextProductProcess; nextw.Input = Accepted; nextw.UpdatedAt = DateTime.Now; db.Wips.Add(nextw); } else { db.Entry(nextw).State = EntityState.Modified; nextw.UpdatedAt = DateTime.Now; //adds the previous accepter quantity nextw.Input = nextw.Input + Accepted; } } }
public static void Calculate(ProductProcess ProductProcess, int Produced, int Rejected, WebApplication5Context db) { Wip w = db.Wips.FirstOrDefault <Wip>(q => q.ProductProcess.ID == ProductProcess.ID); if (w == null) { w = new Wip(); w.ProductProcess = ProductProcess; w.Input = Produced; w.Accepted = Produced - Rejected; w.Rejected = Rejected; w.UpdatedAt = DateTime.Now; db.Wips.Add(w); UpdateNextProcess(ProductProcess, w.Accepted, db); } else { db.Entry(w).State = EntityState.Modified; w.ProductProcess = ProductProcess; if (Produced <= w.Input) { w.Input = w.Input - Produced; w.Accepted = Produced - Rejected; w.Rejected = Rejected; w.UpdatedAt = DateTime.Now; UpdateNextProcess(ProductProcess, w.Accepted, db); } } }
public IHttpActionResult Puttransaction(int id, transaction transaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != transaction.transId) { return(BadRequest()); } db.Entry(transaction).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!transactionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "KitapTuruId,KitapTuruAdi,KitapTuruAciklamasi")] KitapTuru kitapTuru) { if (ModelState.IsValid) { db.Entry(kitapTuru).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(kitapTuru)); }
public ActionResult Edit([Bind(Include = "YazarId,YazarAdiSoyadi,YazarDogumTarihi")] Yazar yazar) { if (ModelState.IsValid) { db.Entry(yazar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(yazar)); }
public ActionResult Edit([Bind(Include = "KitapId,KitapAdi,KitapBasimTarihi,YazarId,KitapTuruId")] Kitap kitap) { if (ModelState.IsValid) { db.Entry(kitap).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.KitapTuruId = new SelectList(db.KitapTurus, "KitapTuruId", "KitapTuruAdi", kitap.KitapTuruId); ViewBag.YazarId = new SelectList(db.Yazars, "YazarId", "YazarAdiSoyadi", kitap.YazarId); return(View(kitap)); }