public async Task <IHttpActionResult> PutEntrySlip(int id, EntrySlip entrySlip) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != entrySlip.Id) { return(BadRequest()); } db.Entry(entrySlip).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EntrySlipExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { EntrySlip entrySlip = db.EntrySlips.Find(id); db.EntrySlips.Remove(entrySlip); db.SaveChanges(); return(RedirectToAction("Index")); }
private void GetEntrySlipId() { if (Session["EntrySlipId"] == null) { EntrySlip entryslip = new EntrySlip(); db.EntrySlips.Add(entryslip); db.SaveChanges(); Session["EntrySlipId"] = entryslip.Id; } }
public ActionResult Edit([Bind(Include = "Id,CreatedDate,Description,DeliveryMan,UserId,ESTypeId,PeriodId")] EntrySlip entrySlip) { if (ModelState.IsValid) { db.Entry(entrySlip).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PeriodId = new SelectList(db.Periods, "Id", "Name", entrySlip.PeriodId); return(View(entrySlip)); }
public async Task <IHttpActionResult> GetEntrySlip(int id) { EntrySlip entrySlip = await db.EntrySlips.FindAsync(id); if (entrySlip == null) { return(NotFound()); } return(Ok(entrySlip)); }
public async Task <IHttpActionResult> PostEntrySlip(EntrySlip entrySlip) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EntrySlips.Add(entrySlip); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = entrySlip.Id }, entrySlip)); }
// GET: EntrySlips/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EntrySlip entrySlip = db.EntrySlips.Find(id); if (entrySlip == null) { return(HttpNotFound()); } return(View(entrySlip)); }
public async Task <IHttpActionResult> DeleteEntrySlip(int id) { EntrySlip entrySlip = await db.EntrySlips.FindAsync(id); if (entrySlip == null) { return(NotFound()); } db.EntrySlips.Remove(entrySlip); await db.SaveChangesAsync(); return(Ok(entrySlip)); }
// GET: EntrySlips/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EntrySlip entrySlip = db.EntrySlips.Find(id); if (entrySlip == null) { return(HttpNotFound()); } ViewBag.PeriodId = new SelectList(db.Periods, "Id", "Name", entrySlip.PeriodId); ViewBag.ESTypeId = new SelectList(db.EntrySlipTypes, "Id", "Name", entrySlip.ESTypeId); return(View(entrySlip)); }