public async Task <IActionResult> Edit(int id, [Bind("ID,NameOfSEB")] SEB sEB) { if (id != sEB.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sEB); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists, " + "see your system administrator."); } } return(View(sEB)); }
// GET: SEB/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SEB sEB = db.SEBs.Find(id); if (sEB == null) { return(HttpNotFound()); } return(View(sEB)); }
public ActionResult DeleteConfirmed(int id) { try { SEB sEB = db.SEBs.Find(id); db.SEBs.Remove(sEB); db.SaveChanges(); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. return(RedirectToAction("Delete", new { id = id, saveChangesError = true })); } return(RedirectToAction("Index")); }
// GET: SEB/Delete/5 public ActionResult Delete(int?id, bool?saveChangesError = false) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator."; } SEB sEB = db.SEBs.Find(id); if (sEB == null) { return(HttpNotFound()); } return(View(sEB)); }
public ActionResult Edit([Bind(Include = "ID,NameOfSEB")] SEB sEB) { if (ModelState.IsValid) { try { db.Entry(sEB).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists, " + "see your system administrator."); } } return(View(sEB)); }
public ActionResult Create(SEB sEB) { try { if (ModelState.IsValid) { db.SEBs.Add(sEB); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(sEB)); }
public async Task <IActionResult> Create(SEB sEB) { try { if (ModelState.IsValid) { _context.Add(sEB); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(sEB)); }
public static Dictionary <string, List <int> > GetPeaks(int[] arr) { Dictionary <string, List <int> > dict = new Dictionary <string, List <int> >(); if (arr.Length <= 1) { new Dictionary <string, List <int> >() { ["pos"] = new List <int>(), ["peaks"] = new List <int>() }; } SEB[] map = new SEB[arr.Length - 1]; int index = 0; var queueTime = arr.Aggregate((p, n) => { if (p < n) { map[index] = SEB.SMALLER; } else if (p == n) { map[index] = SEB.EQUAL; } else { map[index] = SEB.BIGGER; } index++; return(n); }); List <int> pos = new List <int>(); List <int> peaks = new List <int>(); index = 0; var mlist = map.ToList(); var mapTrue = map.Aggregate((p, n) => { int indexNum = index + 1; if (p == SEB.SMALLER && n == SEB.BIGGER)// && (l.LastIndexOf(SEB.SMALLER) > index || l.LastIndexOf(SEB.BIGGER)>index) { pos.Add(indexNum); peaks.Add(arr[indexNum]); } if (p == SEB.SMALLER && n == SEB.EQUAL) { var slice = mlist.GetRange(indexNum, mlist.Count() - indexNum); var bindex = slice.IndexOf(SEB.BIGGER); //-1 var sindex = slice.IndexOf(SEB.SMALLER); //0 if (bindex != -1) { if (bindex < sindex) { pos.Add(indexNum); peaks.Add(arr[indexNum]); } else { if (sindex == -1) { pos.Add(indexNum); peaks.Add(arr[indexNum]); } } } } index++; return(n); }); dict.Add("pos", pos); dict.Add("peaks", peaks); return(dict); }