public ActionResult AddOption(int pollId, string text) { TheBeerHouseDataContext dc = new TheBeerHouseDataContext(); var poll = dc.Polls.GetPoll(pollId); if (poll == null) throw new HttpException(404, "The poll could not be found."); var option = new PollOption { AddedBy = User.Identity.Name, AddedDate = DateTime.Now, OptionText = text, Votes = 0 }; poll.PollOptions.Add(option); dc.SubmitChanges(); return View(new { optionId = option.OptionID, text = text }); }
public static void DeleteOnSubmit(this DbSet<PollOption> source, PollOption pollOption) { source.Remove(pollOption); }