예제 #1
0
        public ActionResult RegisterConfirmed(int id)
        {
            users_in_giveaway users_in_giveaway = new users_in_giveaway();

            users_in_giveaway.fk_giveaway = id;
            users_in_giveaway.fk_user     = (int)Session["Id"];
            user user = db.users.Find((int)Session["Id"]);

            user.fk_giveaway     = id;
            db.Entry(user).State = EntityState.Modified;
            db.SaveChanges();
            db.users_in_giveaway.Add(users_in_giveaway);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
 // GET: Users/Referral/5
 public ActionResult Referral(string id)
 {
     if (Session["Id"] != null)
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         referral referral = db.referrals.Find(id);
         if (referral == null)
         {
             return(HttpNotFound());
         }
         users_in_giveaway users_in_giveaway = new users_in_giveaway();
         users_in_giveaway.fk_giveaway = referral.fk_giveaway;
         users_in_giveaway.fk_user     = (int)Session["Id"];
         var usersGiveaway = db.users_in_giveaway.ToList();
         var boo           = true;
         foreach (var item in usersGiveaway)
         {
             if (item.fk_giveaway == referral.fk_giveaway && item.fk_user == (int)Session["Id"])
             {
                 boo = false;
             }
         }
         if (boo)
         {
             db.users_in_giveaway.Add(users_in_giveaway);
             db.SaveChanges();
             referral.count++;
             db.Entry(referral).State = EntityState.Modified;
             db.SaveChanges();
         }
         return(RedirectToAction("Details", "Giveaways", new { id = referral.fk_giveaway }));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }