Exemplo n.º 1
0
        // GET: Sessions/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest));
            }
            Session session = SessionManager.Get(id.Value);

            if (session == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new SessionsEditViewModel(session);

            return(View(viewModel));
        }
Exemplo n.º 2
0
 public ActionResult Edit(SessionsEditViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             SessionManager.UpdateSessionTimeAndDate(viewModel.SessionId, viewModel.TimeAndDate);
             DataContext.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (CinematicException ex)
         {
             ModelState.AddModelError(string.Empty, ex.Message);
             return(View(viewModel));
         }
     }
     return(View(viewModel));
 }
Exemplo n.º 3
0
        public ActionResult NextStatus(int?id, string targetStatus, SessionsEditViewModel viewModel)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest));
            }
            Session session = SessionManager.Get(id.Value);

            if (session == null)
            {
                return(HttpNotFound());
            }
            else
            {
                try
                {
                    switch (targetStatus)
                    {
                    case "Open":
                        session.Reopen();
                        break;

                    case "Closed":
                        session.Close();
                        break;

                    case "Cancelled":
                        session.Cancel();
                        break;

                    default:
                        break;
                    }
                    DataContext.SaveChanges();
                    return(RedirectToAction("Edit", new { id = id }));
                }
                catch (CinematicException ex)
                {
                    ModelState.AddModelError(string.Empty, ex);
                    return(View("Edit", viewModel));
                }
            }
        }