コード例 #1
0
        //
        // GET: /Speaker/Create
        public ActionResult Add(string id)
        {
            var conference = YouConfDbContext.Conferences
                .FirstOrDefault(x => x.HashTag == id);
            var speaker = new Speaker()
            {
                ConferenceId = conference.Id
            };

            ModelState.Remove("id");
            ViewBag.ConferenceHashTag = id;
            return View(speaker);
        }
コード例 #2
0
        public ActionResult Add(string conferenceHashTag, Speaker speaker)
        {
            if (ModelState.IsValid)
            {
                YouConfDbContext.Speakers.Add(speaker);
                YouConfDbContext.SaveChanges();
                UpdateConferenceInSolrIndex(speaker.ConferenceId, Common.Messaging.SolrIndexAction.Update);

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

            ViewBag.ConferenceId = conferenceHashTag;
            return View(speaker);
        }
コード例 #3
0
        public ActionResult Edit(Speaker speaker)
        {
            if (ModelState.IsValid)
            {
                var currentSpeaker = YouConfDbContext.Speakers
                    .FirstOrDefault(x => x.Id == speaker.Id);
                if (currentSpeaker == null)
                {
                    return HttpNotFound();
                }

                Mapper.Map(speaker, currentSpeaker);
                YouConfDbContext.SaveChanges();
                UpdateConferenceInSolrIndex(currentSpeaker.ConferenceId, Common.Messaging.SolrIndexAction.Update);

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

            ViewBag.ConferenceId = speaker.ConferenceId;
            return View(speaker);
        }