Ejemplo n.º 1
0
 public ActionResult DeleteConfirmed(int id)
 {
     Challenge.Models.Challenge challenge = db.Challenges.Find(id);
     db.Challenges.Remove(challenge);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
 // 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());
        }