public IHttpActionResult PutTblM_Transaksi(int id, TblM_Transaksi tblM_Transaksi) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblM_Transaksi.ID) { return(BadRequest()); } db.Entry(tblM_Transaksi).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TblM_TransaksiExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public JsonResult Tambah(Peminjaman a) { bool status = false; if (ModelState.IsValid) { using (BukuEntities op = new BukuEntities()) { buku aspek = new buku { judul = a.judul }; notaPinjam nota = new notaPinjam { tanggalPinjam = a.tanggalPinjam }; foreach (var item in a.detailpinjam) { aspek.detailPinjam.Add(item); nota.detailPinjam.Add(item); } op.buku.Add(aspek); op.notaPinjam.Add(nota); op.SaveChanges(); status = true; } } else { status = false; } return(new JsonResult { Data = new { status = status } }); }
public JsonResult SavePinjam(Peminjaman O) { bool status = false; if (ModelState.IsValid) { using (BukuEntities dc = new BukuEntities()) { detailPinjam order = new detailPinjam(); notaPinjam not = new notaPinjam { tanggalPinjam = O.tanggalPinjam }; foreach (var i in O.detailpinjam) { not.detailPinjam.Add(i); } //dc.detailPinjam.Add(order); dc.notaPinjam.Add(not); dc.SaveChanges(); status = true; } } else { status = false; } return(new JsonResult { Data = new { status = status } }); }
public ActionResult Create_Post() { var BukuModel = new buku(); TryUpdateModel(BukuModel); using (var r = new BukuEntities()) { r.buku.Add(BukuModel); r.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit_Post(int code) { var BukuModel = new buku(); TryUpdateModel(BukuModel); using (var r = new BukuEntities()) { var b = r.buku.Where(x => x.Id == code).FirstOrDefault(); TryUpdateModel(b); r.SaveChanges(); } return(RedirectToAction("Index")); }