public async Task <PartialViewResult> Vote(bool theUpVote, int?id, int solutionID, string userName) { if (id == null) { return(PartialView()); } SolutionVote solutionVote = await db.SolutionVotes.FindAsync(id); if (solutionVote == null) { solutionVote = new SolutionVote(); solutionVote.CreationDate = DateTime.Now; solutionVote.Solution = await db.Solutions.FindAsync(solutionID); solutionVote.SolutionID = solutionID; 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) { SolutionVote solutionVote = await db.SolutionVotes.FindAsync(id); db.SolutionVotes.Remove(solutionVote); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "VoteID,UserID,upVote,SolutionID")] SolutionVote solutionVote) { if (ModelState.IsValid) { db.Entry(solutionVote).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.SolutionID = new SelectList(db.Solutions, "SolutionID", "Title", solutionVote.SolutionID); return(View(solutionVote)); }
// GET: SolutionVotes/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SolutionVote solutionVote = await db.SolutionVotes.FindAsync(id); if (solutionVote == null) { return(HttpNotFound()); } return(View(solutionVote)); }
// GET: SolutionVotes/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SolutionVote solutionVote = await db.SolutionVotes.FindAsync(id); if (solutionVote == null) { return(HttpNotFound()); } ViewBag.SolutionID = new SelectList(db.Solutions, "SolutionID", "Title", solutionVote.SolutionID); return(View(solutionVote)); }