Exemplo n.º 1
0
        public ActionResult Add(string conferenceHashTag, long[] speakerIds, Presentation presentation)
        {
            var conference = YouConfDbContext.Conferences
                .Include(x => x.Speakers)
                .FirstOrDefault(x => x.HashTag == conferenceHashTag);

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

            if (ModelState.IsValid)
            {
                //Convert the start time to UTC before storing
                presentation.StartTime = ConvertToUtc(presentation.StartTime, conference.TimeZoneId);

                PopulateSpeakers(conference, presentation, speakerIds);
                conference.Presentations.Add(presentation);
                YouConfDbContext.SaveChanges();

                UpdateConferenceInSolrIndex(conference.Id, Common.Messaging.SolrIndexAction.Update);

                return RedirectToAction("Details", "Conference", new { hashTag = conferenceHashTag });
            }

            ViewBag.Conference = conference;
            ViewBag.Speakers = conference.Speakers;
            return View(presentation);
        }
Exemplo n.º 2
0
        //
        // GET: /Presentation/Create
        public ActionResult Add(string id)
        {
            var conference = YouConfDbContext.Conferences
                .FirstOrDefault(x => x.HashTag == id);

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

            ModelState.Remove("id");
            var presentation = new Presentation()
            {
                StartTime = conference.StartDate
            };

            ViewBag.Conference = conference;
            ViewBag.Speakers = conference.Speakers;

            return View(presentation);
        }
Exemplo n.º 3
0
        private void PopulateSpeakers(Conference conference, Presentation presentation, long[] speakerIds)
        {
            presentation.Speakers.Clear();

            //Could look at creating a custom model binder here, but doing it simple for now....
            if (speakerIds == null)
                return;

            foreach (var speakerId in speakerIds)
            {
                var speaker = conference.Speakers.First(x => x.Id == speakerId);
                presentation.Speakers.Add(speaker);
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit(long[] speakerIds, Presentation presentation)
        {
            var currentPresentation = YouConfDbContext.Presentations
                .Include(x => x.Conference)
                .Include(x => x.Conference.Speakers)
                .FirstOrDefault(x => x.Id == presentation.Id);
            if (currentPresentation == null)
            {
                return HttpNotFound();
            }

            if (ModelState.IsValid)
            {
                //Convert the start time to UTC before storing
                presentation.StartTime = ConvertToUtc(presentation.StartTime, currentPresentation.Conference.TimeZoneId);

                //Overwrite the old Presentation details with the new
                Mapper.Map(presentation, currentPresentation);
                PopulateSpeakers(currentPresentation.Conference, currentPresentation, speakerIds);

                YouConfDbContext.SaveChanges();
                UpdateConferenceInSolrIndex(currentPresentation.ConferenceId, Common.Messaging.SolrIndexAction.Update);

                return RedirectToAction("Details", "Conference", new { hashTag = currentPresentation.Conference.HashTag });
            }

            ViewBag.Conference = currentPresentation.Conference;
            ViewBag.Speakers = currentPresentation.Conference.Speakers;
            return View(presentation);
        }