Beispiel #1
0
        public ActionResult Create(int eventid, Session session)
        {
            ViewBag.Event = service.GetEvent(eventid);

            try
            {
                service.CreateSession(new CodeCampService.Session()
                {
                    EventID = eventid,
                    SpeakerID = this.CurrentUser.ID,
                    Name = session.Name,
                    Description = session.Description,
                    Level = Int32.Parse(session.Level),
                    TagID = session.TagID.Value,
                    Status = "SUBMITTED",
                    Location = string.IsNullOrEmpty(session.Location) ? string.Empty : session.Location
                });

                return RedirectToAction("SpeakerSessions");
            }
            catch(Exception)
            {
                return View(session);
            }
        }
        //
        // GET: /Session/Details/5
        public ActionResult Details(int id)
        {
            var session = service.GetSession(id);

            Session model = new Session()
            {
                ID = session.ID,
                Name = session.Name,
                Description = session.Description,
                Speaker = session.Speaker,
                SpeakerID = session.SpeakerID
            };

            return View(model);
        }
Beispiel #3
0
        /// <summary>
        /// Maps a CodeCampService.Session to a Model.Session
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        public static Model.Session Map(this Service.Session session)
        {
            var s = new Model.Session
            {
                ID          = session.ID,
                EventID     = session.EventID,
                Description = session.Description,
                Level       = session.Level.ToString(CultureInfo.InvariantCulture),
                Name        = session.Name,
                Speaker     = session.Speaker,
                SpeakerID   = session.SpeakerID,
                Status      = session.Status,
                Location    = string.IsNullOrEmpty(session.Location) ? string.Empty : session.Location
            };

            return(s);
        }
Beispiel #4
0
        /// <summary>
        /// Maps a Model.Session to a CodeCampService.Session
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        public static Service.Session Map(this Model.Session session)
        {
            int sessionLevel = 0;

            Int32.TryParse(session.Level, out sessionLevel);

            var s = new Service.Session
            {
                ID          = session.ID,
                EventID     = session.EventID,
                Description = session.Description,
                Level       = sessionLevel,
                Name        = session.Name,
                Speaker     = session.Speaker,
                SpeakerID   = session.SpeakerID,
                Status      = session.Status,
                Location    = string.IsNullOrEmpty(session.Location) ? string.Empty : session.Location
            };

            return(s);
        }
Beispiel #5
0
        //
        // GET: /Session/Details/5
        public ActionResult Details(int id)
        {
            var session = service.GetSession(id);

            Session model = new Session()
            {
                ID = session.ID,
                EventID = session.EventID,
                SpeakerID = session.SpeakerID,
                Name = session.Name,
                Description = session.Description,
                Level = session.Level.ToString(),
                Speaker = session.Speaker,
                Status = session.Status,
                ImageUrl = session.ImageUrl,
                StartTime = string.Format("{0}", session.StartTime.HasValue ? session.StartTime.Value.ToShortTimeString() : "N/A"),
                EndTime = string.Format("{0}", session.EndTime.HasValue ? session.EndTime.Value.ToShortTimeString() : "N/A"),
                Location = string.IsNullOrEmpty(session.Location) ? string.Empty : session.Location
            };

            return View(model);
        }
Beispiel #6
0
        //
        // POST: /Session/Delete/5
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                service.DeleteSession(id);
                return RedirectToAction("SpeakerSessions");
            }
            catch
            {
                var session = service.GetSession(id);

                Session model = new Session()
                {
                    ID = session.ID,
                    EventID = session.EventID,
                    SpeakerID = session.SpeakerID,
                    Name = session.Name,
                    Description = session.Description,
                    Level = session.Level.ToString(),
                    Speaker = session.Speaker,
                    Status = session.Status,
                    Location = string.IsNullOrEmpty(session.Location) ? string.Empty : session.Location
                };

                return View("Details", model);
            }
        }
Beispiel #7
0
        public ActionResult Edit(Session session)
        {
            try
            {
                var savedSession = service.GetSession(session.ID);
                savedSession.Name = session.Name;
                savedSession.Description = session.Description;
                savedSession.Level = Int32.Parse(session.Level);
                savedSession.TagID = session.TagID.Value;
                service.UpdateSession(savedSession);

                return RedirectToAction("SpeakerSessions");
            }
            catch
            {
                return View(session);
            }
        }
Beispiel #8
0
        public ActionResult Edit(int id)
        {
            var session = service.GetSession(id);
            var result = service.GetTags();
            ViewBag.Tags = result;

            if (session.SpeakerID == CurrentUser.ID)
            {
                Session model = new Session()
                {
                    ID = session.ID,
                    EventID = session.EventID,
                    SpeakerID = session.SpeakerID,
                    Name = session.Name,
                    Description = session.Description,
                    Level = session.Level.ToString(),
                    Speaker = session.Speaker,
                    Status = session.Status,
                    TagID = session.TagID,
                    Location = string.IsNullOrEmpty(session.Location) ? string.Empty : session.Location
                };

                return View(model);
            }
            else
            {
                return RedirectToAction("SpeakerSessions");
            }
        }
Beispiel #9
0
 /// <summary>
 /// Maps a CodeCampService.Session to a Model.Session
 /// </summary>
 /// <param name="session"></param>
 /// <returns></returns>
 public static Model.Session Map(this Service.Session session)
 {
     var s = new Model.Session
     {
         ID = session.ID,
         EventID = session.EventID,
         Description = session.Description,
         Level = session.Level.ToString(CultureInfo.InvariantCulture),
         Name = session.Name,
         Speaker = session.Speaker,
         SpeakerID = session.SpeakerID,
         Status = session.Status,
         Location = string.IsNullOrEmpty(session.Location) ? string.Empty : session.Location
     };
     return s;
 }