public ActionResult Edit([Bind(Include = "SourceId,ResultId,Amount")] FailsIntoPair failsIntoPair) { if (ModelState.IsValid) { db.Entry(failsIntoPair).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ResultId = new SelectList(db.Products, "Id", "Name", failsIntoPair.ResultId); ViewBag.SourceId = new SelectList(db.Products, "Id", "Name", failsIntoPair.SourceId); return(View(failsIntoPair)); }
public ActionResult CreateFailureWithSource([Bind(Include = "SourceId,ResultId,Amount")] FailsIntoPair failsIntoPair) { if (ModelState.IsValid) { db.FailurePairs.Add(failsIntoPair); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ResultId = new SelectList(db.Products, "Id", "Name", failsIntoPair.ResultId); ViewBag.SourceId = new SelectList(db.Products, "Id", "Name", failsIntoPair.SourceId); return(View(failsIntoPair)); }
public ActionResult DeleteConfirmed(int?sourceId, int?resultId) { if (sourceId == null || resultId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FailsIntoPair failsIntoPair = db.FailurePairs .Single(x => x.SourceId == sourceId && x.ResultId == resultId); db.FailurePairs.Remove(failsIntoPair); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: FailsIntoPairs/Delete/5 public ActionResult Delete(int?sourceId, int?resultId) { if (sourceId == null || resultId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FailsIntoPair failsIntoPair = db.FailurePairs .Single(x => x.SourceId == sourceId && x.ResultId == resultId); if (failsIntoPair == null) { return(HttpNotFound()); } return(View(failsIntoPair)); }
// GET: FailsIntoPairs/Edit/5 public ActionResult Edit(int?sourceId, int?resultId) { if (sourceId == null || resultId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FailsIntoPair failsIntoPair = db.FailurePairs.Single(x => x.SourceId == sourceId && x.ResultId == resultId); if (failsIntoPair == null) { return(HttpNotFound()); } ViewBag.ResultId = new SelectList(db.Products, "Id", "Name", failsIntoPair.ResultId); ViewBag.SourceId = new SelectList(db.Products, "Id", "Name", failsIntoPair.SourceId); return(View(failsIntoPair)); }
public ActionResult Create([Bind(Include = "SourceId,ResultId,Amount")] FailsIntoPair failsIntoPair) { if (ModelState.IsValid) { db.FailurePairs.Add(failsIntoPair); // if it already exists if (db.FailurePairs.Any(x => x.SourceId == failsIntoPair.SourceId && x.ResultId == failsIntoPair.ResultId)) { // return a conflict from the DB // TODO: Improve this so when it happens people know why. return(new HttpStatusCodeResult(HttpStatusCode.Conflict)); } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ResultId = new SelectList(db.Products, "Id", "Name", failsIntoPair.ResultId); ViewBag.SourceId = new SelectList(db.Products, "Id", "Name", failsIntoPair.SourceId); return(View(failsIntoPair)); }