Exemplo n.º 1
0
        // GET: List of SessionType
        public ActionResult Index()
        {
            var service = new SessionTypeService();
            var model   = service.GetSessionTypes();

            return(View(model));
        }
Exemplo n.º 2
0
        //GET DETAILS by ID
        public ActionResult Details(int id)
        {
            var service = new SessionTypeService();
            var model   = service.GetSessionTypeByID(id);

            return(View(model));
        }
        public ActionResult Edit(int id, SessionEdit model)
        {
            var sessionService  = new SessionTypeService();
            var sessionTypeList = sessionService.GetSessionTypes();

            ViewBag.SessionTypeID = new SelectList(sessionTypeList, "SessionTypeID", "Name", model.SessionTypeID);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //if(model.SessionID != id)
            //{
            //    ModelState.AddModelError("", "Id Mismatch");
            //    return View(model);
            //}

            var service = GetSessionService();

            if (service.EditSession(model))
            {
                TempData["Save Result"] = "Your session was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your session could not be updated.");
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Index()
        {
            var sessionTypeService = new SessionTypeService();
            var sessionTypeList    = sessionTypeService.GetSessionTypes();

            ViewBag.SessionTypeID = new SelectList(sessionTypeList, "SessionTypeID", "Name");

            return(View());
        }
Exemplo n.º 5
0
        public ActionResult DeleteSessionType(int id)
        {
            var service = new SessionTypeService();

            if (service.DeleteSessionType(id))
            {
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Delete", new { id }));
        }
Exemplo n.º 6
0
        public ActionResult Create(SessionTypeCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new SessionTypeService();

            if (service.CreateSessionType(model))
            {
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Session type could not be added");
            return(View(model));
        }
Exemplo n.º 7
0
        //Edit by Id
        public ActionResult Edit(int id)
        {
            var service = new SessionTypeService();
            var detail  = service.GetSessionTypeByID(id);

            var model = new SessionTypeEdit
            {
                SessionTypeID = detail.SessionTypeID,
                Name          = detail.Name,
                PricePerHour  = detail.PricePerHour
            };

            var sessionService  = new SessionTypeService();
            var sessionTypeList = sessionService.GetSessionTypes();

            ViewBag.SessionTypeID = new SelectList(sessionTypeList, "SessionTypeID", "Name", model.SessionTypeID);

            return(View(model));
        }
        //EDIT
        public ActionResult Edit(int id)
        {
            var service = GetSessionService();
            var detail  = service.GetSessionByID(id);
            var model   = new SessionEdit
            {
                SessionID     = detail.SessionID,
                SessionTypeID = detail.SessionTypeID,
                StartTime     = detail.StartTime,
                EndTime       = detail.EndTime,
                Extras        = detail.Extras
            };

            var sessionService  = new SessionTypeService();
            var sessionTypeList = sessionService.GetSessionTypes();

            ViewBag.SessionTypeID = new SelectList(sessionTypeList, "SessionTypeID", "Name", model.SessionTypeID);

            return(View(model));
        }
Exemplo n.º 9
0
        public ActionResult Index(SessionCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = GetSessionService();

            if (service.CreateSession(model))
            {
                return(RedirectToAction("Index", "Session"));
            }

            var sessionService  = new SessionTypeService();
            var sessionTypeList = sessionService.GetSessionTypes();

            ViewBag.SessionTypeID = new SelectList(sessionTypeList, "SessionTypeID", "Name");

            return(View(model));
        }
Exemplo n.º 10
0
        public ActionResult Edit(SessionTypeEdit model)
        {
            var sessionService  = new SessionTypeService();
            var sessionTypeList = sessionService.GetSessionTypes();

            ViewBag.SessionTypeID = new SelectList(sessionTypeList, "SessionTypeID", "Name", model.SessionTypeID);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new SessionTypeService();

            if (service.EditSessionType(model))
            {
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Session type could not be updated.");
            return(View(model));
        }