// // GET: /Grade/Edit/5 public ActionResult Edit(int id) { Storage m = new Storage(); Grade grade = m.getGradeById(id); Models.Grade.CreateModel model = new Models.Grade.CreateModel(); model.NewGrade = grade; model.Realizations = getRealisationSelectList(grade.RealisationID.ToString()); return View(model); }
public ActionResult Edit(int id, FormCollection collection) { try { string name = Convert.ToString(collection["NewGrade.Name"]); int realisation = Convert.ToInt32(collection["NewGrade.RealisationID"]); string maxValue = Convert.ToString(collection["NewGrade.MaxValue"]); if (string.IsNullOrEmpty(name)) ModelState.AddModelError("nazwa", "Musisz podać nazwę oceny!"); if(string.IsNullOrEmpty(maxValue)) ModelState.AddModelError("max wartosc", "Musisz podać maksymalna wartos!"); if (ModelState.IsValid) { Storage m = new Storage(); Grade grade = m.getGradeById(id); m.updateGrade(id, name, maxValue, realisation, grade.TimeStamp); } else { Storage m = new Storage(); Grade grade = m.getGradeById(id); Models.Grade.CreateModel model = new Models.Grade.CreateModel(); model.NewGrade = grade; model.Realizations = getRealisationSelectList(grade.RealisationID.ToString()); return View(model); } } catch (EresDataContextException e) { handleException(e); } catch { } return RedirectToAction("Index"); }
public ActionResult Delete(int id, FormCollection collection) { try { Storage m = new Storage(); Grade grade = m.getGradeById(id); m.deleteGrade(grade); } catch(EresDataContextException e) { handleException(e); } return RedirectToAction("Index"); }
// // GET: /Grade/Delete/5 public ActionResult Delete(int id) { Storage m = new Storage(); Grade grade = m.getGradeById(id); return View(grade); }