public ActionResult PollResult(int id) { var ctx = new ApplicationDbContext(); var mp = ctx.MeetingPolls.FirstOrDefault(m => m.Id == id); var view = new MeetingPollResultViewModel() { PollId = mp.Id, AuthorId = mp.Author.Id, Title = mp.Title, Content = mp.Content, Participants = mp.Participants, PollOptions = mp.PollOptions }; return View(view); }
public ActionResult CreateMeeting(MeetingPollResultViewModel model) { var ctx = new ApplicationDbContext(); var poll = ctx.MeetingPolls.FirstOrDefault(p => p.Id == model.PollId); var meeting = new Meeting() { Title = poll.Title, Content = poll.Content, MeetingTime = model.Result, Author = poll.Author, Participants = poll.Participants.ToList() }; ctx.Meetings.Add(meeting); ctx.MeetingPolls.Remove(poll); ctx.SaveChanges(); return RedirectToAction("Index"); }