public ActionResult Edit([Bind(Include = "ID,Description")] ProblemArea problemArea) { try { if (ModelState.IsValid) { db.Entry(problemArea).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException dex) { if (dex.InnerException.InnerException.Message.Contains("IX_Description")) { ModelState.AddModelError("", "Unable to create. Location with this name already exist."); } else { ModelState.AddModelError("", $"Database Error: {dex.InnerException.InnerException.Message}"); } } catch (Exception ex) { ModelState.AddModelError("", $"Error! {ex.Message}"); } return(View(problemArea)); }
public ActionResult DeleteConfirmed(int id) { ProblemArea problemArea = db.ProblemAreas.Find(id); db.ProblemAreas.Remove(problemArea); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ID,Description")] ProblemArea problemArea) { if (ModelState.IsValid) { db.ProblemAreas.Add(problemArea); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(problemArea)); }
// GET: ProblemAreas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProblemArea problemArea = db.ProblemAreas.Find(id); if (problemArea == null) { return(HttpNotFound()); } return(View(problemArea)); }
private List <int> SolveSingleProblemAreaPadding(ProblemArea problemArea, int paddingCount, int minimalLeft = 0) { var solution = new List <int>(paddingCount - minimalLeft + 1); for (int left = minimalLeft; left <= paddingCount; left++) { var right = paddingCount - left; if (ProblemAreaPaddingWorks(problemArea, left, right)) { solution.Add(left); } } return(solution); }
private bool ProblemAreaPaddingWorks(ProblemArea problemArea, int left, int right) { foreach (var time in problemArea.timesToCheck) { var minimalLeft = time - approachTime; var minimalRight = time + approachTime; var startIndex = PaddedOsuBinarySearch(minimalLeft, left, right); var endIndex = hitObjects.FindIndex(startIndex, ho => ho.Time > minimalRight); if (endIndex < 0) { endIndex = hitObjects.Count - 1; } if (startIndex > problemArea.index || endIndex < problemArea.index || time > autoFailCheckTime) { return(false); } } return(true); }