public async Task <PartialViewResult> Vote(bool theUpVote, int?id, int channelID, string userName) { if (id == null) { return(PartialView()); } ChannelVote solutionVote = await db.ChannelVotes.FindAsync(channelID); if (solutionVote == null) { solutionVote = new ChannelVote(); solutionVote.CreationDate = DateTime.Now; solutionVote.Channel = await db.Channels.FindAsync(channelID); solutionVote.ChannelID = channelID; solutionVote.UserID = userName; } else { solutionVote.upVote = theUpVote; db.Entry(solutionVote).State = EntityState.Modified; } await db.SaveChangesAsync(); return(PartialView(solutionVote)); }
public async Task <ActionResult> DeleteConfirmed(int id) { ChannelVote channelVote = await db.ChannelVotes.FindAsync(id); db.ChannelVotes.Remove(channelVote); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "VoteID,UserID,upVote,ChannelID")] ChannelVote channelVote) { if (ModelState.IsValid) { db.Entry(channelVote).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.ChannelID = new SelectList(db.Channels, "ChannelID", "Title", channelVote.ChannelID); return(View(channelVote)); }
public async Task <ActionResult> Create([Bind(Include = "VoteID,UserID,upVote,ChannelID")] ChannelVote channelVote) { if (ModelState.IsValid) { channelVote.CreationDate = DateTime.Now; db.ChannelVotes.Add(channelVote); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.ChannelID = new SelectList(db.Channels, "ChannelID", "Title", channelVote.ChannelID); return(View(channelVote)); }
// GET: ChannelVotes/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChannelVote channelVote = await db.ChannelVotes.FindAsync(id); if (channelVote == null) { return(HttpNotFound()); } return(View(channelVote)); }
// GET: ChannelVotes/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChannelVote channelVote = await db.ChannelVotes.FindAsync(id); if (channelVote == null) { return(HttpNotFound()); } ViewBag.ChannelID = new SelectList(db.Channels, "ChannelID", "Title", channelVote.ChannelID); return(View(channelVote)); }