public ActionResult Commit(ViewSkatingSession skatingSession) { // get RegistrationTerm from RegistrationTermID var term = session.Get<RegistrationTerm>(skatingSession.RegistrationTermID); var realSession = skatingSession.ToSkatingSession(); if (!term.SkatingSessions.Any(s => s.ID == realSession.ID)) { term.SkatingSessions.Add(realSession); } session.SaveOrUpdate(realSession); session.SaveOrUpdate(term); Console.WriteLine( new System.Web.Script.Serialization.JavaScriptSerializer().Serialize (term.SkatingSessions)); TempData["message"] = String.Format("Skating session '{0}' saved.", skatingSession.ID); return RedirectToAction("Index", new { id = term.ID}); }
public ActionResult Edit(int id) { var skatingSession = session.Get<SkatingSession>(id); if (skatingSession == null) { return RedirectToAction("Index"); } var term = session.Query<RegistrationTerm>() .SingleOrDefault(t => t.SkatingSessions.Any(s => s.ID == skatingSession.ID)); if (term == null) { return RedirectToAction("Index"); } var viewSkatingSession = new ViewSkatingSession(skatingSession, term.ID); return View (viewSkatingSession); }