public ActionResult DeleteConfirmed(int id) { Challenge.Models.Challenge challenge = db.Challenges.Find(id); db.Challenges.Remove(challenge); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Name,CreatedOn,EndsOn")] Challenge.Models.Challenge challenge) { if (ModelState.IsValid) { db.Entry(challenge).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(challenge)); }
public ActionResult Create([Bind(Include = "Id,Name,CreatedOn,EndsOn")] Challenge.Models.Challenge challenge) { if (ModelState.IsValid) { db.Challenges.Add(challenge); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(challenge)); }
// GET: Challenges/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Challenge.Models.Challenge challenge = db.Challenges.Find(id); if (challenge == null) { return(HttpNotFound()); } return(View(challenge)); }
public ActionResult AddParticipantToChallenge(int id) { Challenge.Models.Challenge challenge = db.Challenges.Find(id); ApplicationUser applicationUser = db.Users.Find(User.Identity.GetUserId()); if (User.Identity.IsAuthenticated) { challenge.Participants.Add(applicationUser); db.SaveChanges(); return(RedirectToAction("Index", db.Challenges.ToList())); } return(HttpNotFound()); }