//
        // GET: /Factures/

        public ActionResult Index(string identnutter)
        {
            // Recherche du nutter
            AWLFacebookContext contextNuttersFacebook2 = new AWLFacebookContext();
            AWLFacebookProfile nutterDefacebookreel    = contextNuttersFacebook2.FacebookNuttersTable.FirstOrDefault((o => o.UserId.Equals(identnutter)));

            // Split du buyer
            // Pour les achats d'avant effectués par le nutter
            AWLFacturesContext contextFactures       = new AWLFacturesContext();
            List <AWLFacture>  tablePaiementsNutters = contextFactures.FacturesTable.ToList();
            List <AWLFacture>  vraiTableau           = new List <AWLFacture>();

            for (int u = 0; u < tablePaiementsNutters.Count; u++)
            {
                if (tablePaiementsNutters.ElementAt(u).Buyer.Count(f => f == '/') >= 1)
                {
                    string[] split   = tablePaiementsNutters.ElementAt(u).Buyer.Split('/');
                    int      endroit = tablePaiementsNutters.ElementAt(u).Buyer.Count(f => f == '/');
                    if (split[endroit] == identnutter)
                    {
                        vraiTableau.Add(tablePaiementsNutters.ElementAt(u));
                    }
                }
            }

            // Transmission des listes des achats précédemment effectués
            ViewBag.resultat = vraiTableau;

            return(View());
        }
Ejemplo n.º 2
0
        public string getNutterUserFacebook()
        {
            string             valeurglobale = System.Web.HttpContext.Current.Session["idfbk"] as string;
            AWLFacebookContext contexte      = new AWLFacebookContext();
            string             usernamereal  = contexte.FacebookNuttersTable.FirstOrDefault(u => u.UserId.Equals(valeurglobale)).UserName;

            return(usernamereal);
        }
Ejemplo n.º 3
0
        public string EndGame(string idMoi, string idPartieJeu, string position, int score1fin, int score2fin)
        {
            // Si c'est un facebook user, on stocke les scores dans le modèle facebook
            string valeuridfacebook = System.Web.HttpContext.Current.Session["idfbk"] as string;

            ViewBag.idfbk = valeuridfacebook;
            AWLFacebookContext db   = new AWLFacebookContext();
            AWLFacebookProfile user = db.FacebookNuttersTable.FirstOrDefault(u => u.UserId.Equals(valeuridfacebook));

            if (position == "1")
            {
                user.UserNuts1 = user.UserNuts1 + score1fin;
                user.UserBonus = user.UserBonus + score1fin * 10;
                // Mise à jour des noix d'or, de bronze et simples
                while (user.UserNuts1 > 30)
                {
                    int restesimple = user.UserNuts1 - 30;
                    user.UserNuts2 = user.UserNuts2 + 1;
                    user.UserNuts1 = restesimple;
                }
                while (user.UserNuts2 > 10)
                {
                    int restesimple2 = user.UserNuts2 - 10;
                    user.UserNuts3 = user.UserNuts3 + 1;
                    user.UserNuts2 = restesimple2;
                }
                db.SaveChanges();
                // Destruction de la partie par l'initiateur seul de la partie
                int positionmoi = PartiesNames.IndexOf(idPartieJeu);
                PartiesCln.RemoveAt(positionmoi);
                PartiesNames.RemoveAt(positionmoi);
            }
            else if (position == "2")
            {
                user.UserNuts1 = user.UserNuts1 + score2fin;
                user.UserBonus = user.UserBonus + score2fin * 10;
                // Mise à jour des noix d'or, de bronze et simples
                while (user.UserNuts1 > 30)
                {
                    int restesimple = user.UserNuts1 - 30;
                    user.UserNuts2 = user.UserNuts2 + 1;
                    user.UserNuts1 = restesimple;
                }
                while (user.UserNuts2 > 10)
                {
                    int restesimple2 = user.UserNuts2 - 10;
                    user.UserNuts3 = user.UserNuts3 + 1;
                    user.UserNuts2 = restesimple2;
                }
                db.SaveChanges();
            }

            //System.Web.HttpContext.Current.User.Identity.Name
            return("Fin du jeu !");
        }
        //
        // POST: /Account/Register

        public string RegisterFbk(string idfk, string usernamefk, string emailfk)
        {
            // Tentative d'inscription de l'utilisateur par Facebook
            try
            {
                // On crée le compte facebook nutter dans notre base de données
                AWLFacebookContext contextNuttersFacebook = new AWLFacebookContext();

                if (!(contextNuttersFacebook.FacebookNuttersTable.Any(o => o.UserId.Equals(idfk))))
                {
                    AWLFacebookProfile nutterDefacebook = new AWLFacebookProfile();
                    nutterDefacebook.UserId    = idfk;
                    nutterDefacebook.UserName  = usernamefk;
                    nutterDefacebook.Email     = emailfk;
                    nutterDefacebook.UserNuts1 = 30;
                    nutterDefacebook.UserNuts2 = 0;
                    nutterDefacebook.UserNuts3 = 0;
                    nutterDefacebook.UserBonus = 0;
                    nutterDefacebook.UserLevel = 1;
                    contextNuttersFacebook.FacebookNuttersTable.Add(nutterDefacebook);


                    contextNuttersFacebook.SaveChanges();


                    // ... et on l'envoit à l'utilisateur facebook par email
                    // MailingService5 mailingService = new MailingService5();
                    // mailingService.SendTokenByEmail(confirmationToken, model.Email, model.UserName);

                    ViewData["ici"]   = "facebook";
                    ViewData["idfbk"] = idfk;
                    ViewBag.idfbk     = idfk;
                    System.Web.HttpContext.Current.Session["idfbk"]    = idfk;
                    System.Web.HttpContext.Current.Session["fbkornot"] = "fbk";
                    return("OKRA");
                }
                else
                {
                    ViewData["ici"]   = "facebook";
                    ViewData["idfbk"] = idfk;
                    ViewBag.idfbk     = idfk;
                    System.Web.HttpContext.Current.Session["idfbk"]    = idfk;
                    System.Web.HttpContext.Current.Session["fbkornot"] = "fbk";
                    return("KO");
                }
            }
            catch (Exception e)
            {
                return("KOA");
            }
        }
Ejemplo n.º 5
0
        public string canyouplay(string idmoimatches)
        {
            AWLFacebookContext db   = new AWLFacebookContext();
            AWLFacebookProfile user = db.FacebookNuttersTable.FirstOrDefault(u => u.UserId.Equals(idmoimatches));

            if ((user.UserNuts1 >= 15) ||
                (user.UserNuts1 < 15 && user.UserNuts2 >= 1) || (user.UserNuts1 < 15 && user.UserNuts2 < 1 && user.UserNuts3 >= 1))
            {
                if (user.UserNuts1 >= 15)
                {
                    user.UserNuts1 = user.UserNuts1 - 15;
                }
                else if (user.UserNuts1 < 15 && user.UserNuts2 >= 1)
                {
                    user.UserNuts2 = user.UserNuts2 - 1;
                    user.UserNuts1 = user.UserNuts1 + 15;
                }
                else if (user.UserNuts1 < 15 && user.UserNuts2 < 1 && user.UserNuts3 >= 1)
                {
                    user.UserNuts3 = user.UserNuts3 - 1;
                    user.UserNuts2 = user.UserNuts2 + 9;     //(+10-1)
                    user.UserNuts1 = user.UserNuts1 + 15;
                }

                // Conversions
                while (user.UserNuts1 > 30)
                {
                    int restesimple = user.UserNuts1 - 30;
                    user.UserNuts2 = user.UserNuts2 + 1;
                    user.UserNuts1 = restesimple;
                }
                while (user.UserNuts2 > 10)
                {
                    int restesimple2 = user.UserNuts2 - 10;
                    user.UserNuts3 = user.UserNuts3 + 1;
                    user.UserNuts2 = restesimple2;
                }

                // Enregistrement
                db.SaveChanges();

                return("OK");
            }
            else
            {
                return("KO");
            }
        }
        /*public string demandeCompteFacebook()
         * {
         *  ViewData["fbk"] = "pauline";
         *  //ViewData["fbkOK"] = "OK";
         *  // Rafraichir la partial view
         *
         *  return "OK";
         * }*/

        public ActionResult partialfbk(string idnombre, string idnom)
        {
            AWLFacebookContext contextNuttersFacebook2 = new AWLFacebookContext();
            AWLFacebookProfile nutterDefacebookreel    = contextNuttersFacebook2.FacebookNuttersTable.FirstOrDefault((o => o.UserId.Equals(idnombre)));

            ViewData["noix1"] = nutterDefacebookreel.UserNuts1;
            ViewData["noix2"] = nutterDefacebookreel.UserNuts2;
            ViewData["noix3"] = nutterDefacebookreel.UserNuts3;
            ViewData["noixb"] = nutterDefacebookreel.UserBonus;

            ViewData["fbk"]   = idnom;
            ViewData["idfbk"] = idnombre;
            ViewBag.idfbk     = idnombre;
            System.Web.HttpContext.Current.Session["idfbk"]    = idnombre;
            System.Web.HttpContext.Current.Session["fbkornot"] = "fbk";

            return(PartialView("_LoginPartialFbk"));
        }
        // GET: /Account/Manage

        public ActionResult Manage(string identifiant)
        {
            // Pour les scores du user facebook
            AWLFacebookContext contextNuttersFacebook2 = new AWLFacebookContext();
            AWLFacebookProfile nutterDefacebookreel    = contextNuttersFacebook2.FacebookNuttersTable.FirstOrDefault((o => o.UserId.Equals(identifiant)));

            ViewBag.n1           = nutterDefacebookreel.UserNuts1.ToString();
            ViewBag.n2           = nutterDefacebookreel.UserNuts2.ToString();
            ViewBag.n3           = nutterDefacebookreel.UserNuts3.ToString();
            ViewBag.b            = nutterDefacebookreel.UserBonus.ToString();
            ViewBag.levelreached = nutterDefacebookreel.UserLevel.ToString();

            ViewBag.meilleurbonus = contextNuttersFacebook2.FacebookNuttersTable.Max(u => u.UserBonus).ToString();
            int    j1  = contextNuttersFacebook2.FacebookNuttersTable.Max(u => u.UserBonus);
            string jj1 = contextNuttersFacebook2.FacebookNuttersTable.FirstOrDefault(u => u.UserBonus.Equals(j1)).UserName;

            ViewBag.meilleurn1 = contextNuttersFacebook2.FacebookNuttersTable.Max(u => u.UserNuts1).ToString();
            int    j2  = contextNuttersFacebook2.FacebookNuttersTable.Max(u => u.UserNuts1);
            string jj2 = contextNuttersFacebook2.FacebookNuttersTable.FirstOrDefault(u => u.UserNuts1.Equals(j2)).UserName;

            ViewBag.meilleurn2 = contextNuttersFacebook2.FacebookNuttersTable.Max(u => u.UserNuts2).ToString();
            int    j3  = contextNuttersFacebook2.FacebookNuttersTable.Max(u => u.UserNuts2);
            string jj3 = contextNuttersFacebook2.FacebookNuttersTable.FirstOrDefault(u => u.UserNuts2.Equals(j3)).UserName;

            ViewBag.meilleurn3 = contextNuttersFacebook2.FacebookNuttersTable.Max(u => u.UserNuts3).ToString();
            int    j4  = contextNuttersFacebook2.FacebookNuttersTable.Max(u => u.UserNuts3);
            string jj4 = contextNuttersFacebook2.FacebookNuttersTable.FirstOrDefault(u => u.UserNuts3.Equals(j4)).UserName;

            ViewBag.meilleurn3user    = jj4;
            ViewBag.meilleurn2user    = jj3;
            ViewBag.meilleurn1user    = jj2;
            ViewBag.meilleurbonususer = jj1;

            ViewBag.idnutterfacebook = identifiant;

            return(View());
        }
Ejemplo n.º 8
0
        //
        // GET: /ApplicationReal/

        //public ActionResult Index()
        //{
        //    return View();
        //}

        public string RegisterAllFbk(string idfk, string usernamefk, string emailfk)
        {
            try
            {
                ViewData["ici"]   = "facebook";
                ViewData["idfbk"] = idfk;
                ViewBag.idfbk     = idfk;
                System.Web.HttpContext.Current.Session["idfbk"]    = idfk;
                System.Web.HttpContext.Current.Session["fbkornot"] = "fbk";
                string             valeurglobale = System.Web.HttpContext.Current.Session["idfbk"] as string;
                AWLFacebookContext contexte      = new AWLFacebookContext();
                string             usernamereal  = contexte.FacebookNuttersTable.FirstOrDefault(u => u.UserId.Equals(valeurglobale)).UserName;
                ViewData["fbk"] = usernamereal;
                ViewBag.fbk     = usernamereal;
                return("KO");

                // APPEL NOM ICI
                return("OK");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 9
0
        public string EndGame(string idMoi, string position, int score1fin, int score2fin)
        {
            /*// Les scores sont là, il ne reste qu'à les mettre dans les VRAIS profils
             * PartiesCln.ElementAt(PartiesNames.IndexOf(idPartieHub)).player1.score = score1fin;
             * PartiesCln.ElementAt(PartiesNames.IndexOf(idPartieHub)).player2.score = score2fin;
             * PartiesCln.ElementAt(PartiesNames.IndexOf(idPartieHub)).player1.scorebonus = score1fin * 100;
             * PartiesCln.ElementAt(PartiesNames.IndexOf(idPartieHub)).player2.scorebonus = score2fin * 100;
             */
            string valeurglobale;

            if (System.Web.HttpContext.Current.Session["idfbk"] != null)
            {
                valeurglobale = System.Web.HttpContext.Current.Session["idfbk"] as string;
                ViewBag.idfbk = valeurglobale;
                if (!string.IsNullOrEmpty(valeurglobale))
                {
                    // Si c'est un nutter facebook, on stocke les scores dans le modèle
                    AWLFacebookContext db   = new AWLFacebookContext();
                    AWLFacebookProfile user = db.FacebookNuttersTable.FirstOrDefault(u => u.UserId.Equals(valeurglobale));
                    if (position == "1")
                    {
                        user.UserNuts1 = user.UserNuts1 + score1fin;
                        user.UserBonus = user.UserBonus + score1fin * 10;
                        // Mise à jour des noix d'or, de bronze et simples
                        while (user.UserNuts1 > 30)
                        {
                            int restesimple = user.UserNuts1 - 30;
                            user.UserNuts2 = user.UserNuts2 + 1;
                            user.UserNuts1 = restesimple;
                        }
                        while (user.UserNuts2 > 10)
                        {
                            int restesimple2 = user.UserNuts2 - 10;
                            user.UserNuts3 = user.UserNuts3 + 1;
                            user.UserNuts2 = restesimple2;
                        }
                        db.SaveChanges();
                        // Destruction de la partie par l'initiateur seul de la partie
                        int positionmoi = PartiesNames.IndexOf(idMoi);
                        PartiesCln.RemoveAt(positionmoi);
                        PartiesNames.RemoveAt(positionmoi);
                    }
                    else if (position == "2")
                    {
                        user.UserNuts1 = user.UserNuts1 + score2fin;
                        user.UserBonus = user.UserBonus + score2fin * 10;
                        // Mise à jour des noix d'or, de bronze et simples
                        while (user.UserNuts1 > 30)
                        {
                            int restesimple = user.UserNuts1 - 30;
                            user.UserNuts2 = user.UserNuts2 + 1;
                            user.UserNuts1 = restesimple;
                        }
                        while (user.UserNuts2 > 10)
                        {
                            int restesimple2 = user.UserNuts2 - 10;
                            user.UserNuts3 = user.UserNuts3 + 1;
                            user.UserNuts2 = restesimple2;
                        }
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                if (enregistre)
                {
                    // Si c'est un nutter user, on stocke les scores dans le modèle du user courant
                    UsersContext db   = new UsersContext();
                    UserProfile  user = db.UserProfiles.FirstOrDefault(u => u.UserName.Equals(User.Identity.Name));
                    if (position == "1")
                    {
                        user.UserNuts1 = user.UserNuts1 + score1fin;
                        user.UserBonus = user.UserBonus + score1fin * 10;
                        // Mise à jour des noix d'or, de bronze et simples
                        while (user.UserNuts1 > 30)
                        {
                            int restesimple = user.UserNuts1 - 30;
                            user.UserNuts2 = user.UserNuts2 + 1;
                            user.UserNuts1 = restesimple;
                        }
                        while (user.UserNuts2 > 10)
                        {
                            int restesimple2 = user.UserNuts2 - 10;
                            user.UserNuts3 = user.UserNuts3 + 1;
                            user.UserNuts2 = restesimple2;
                        }
                        db.SaveChanges();
                        // Destruction de la partie par l'initiateur seul de la partie
                        int positionmoi = PartiesNames.IndexOf(idMoi);
                        PartiesCln.RemoveAt(positionmoi);
                        PartiesNames.RemoveAt(positionmoi);
                    }
                    else if (position == "2")
                    {
                        user.UserNuts1 = user.UserNuts1 + score2fin;
                        user.UserBonus = user.UserBonus + score2fin * 10;
                        // Mise à jour des noix d'or, de bronze et simples
                        while (user.UserNuts1 > 30)
                        {
                            int restesimple = user.UserNuts1 - 30;
                            user.UserNuts2 = user.UserNuts2 + 1;
                            user.UserNuts1 = restesimple;
                        }
                        while (user.UserNuts2 > 10)
                        {
                            int restesimple2 = user.UserNuts2 - 10;
                            user.UserNuts3 = user.UserNuts3 + 1;
                            user.UserNuts2 = restesimple2;
                        }
                        db.SaveChanges();
                    }
                }
                else
                {
                    // Création des variables de session pour les nutters anonymes et stockage des scores
                    if (position == "1")
                    {
                        if (System.Web.HttpContext.Current.Session["nutterAnonymous"] != null)
                        {
                            System.Web.HttpContext.Current.Session["nutterAnonymous"] = (int)System.Web.HttpContext.Current.Session["nutterAnonymous"] + score1fin;
                        }
                        else
                        {
                            System.Web.HttpContext.Current.Session["nutterAnonymous"] = score1fin;
                        }
                        // Destruction de la partie par l'initiateur seul de la partie
                        int positionmoi = PartiesNames.IndexOf(idMoi);
                        PartiesCln.RemoveAt(positionmoi);
                        PartiesNames.RemoveAt(positionmoi);
                    }
                    else if (position == "2")
                    {
                        if (System.Web.HttpContext.Current.Session["nutterAnonymous"] != null)
                        {
                            System.Web.HttpContext.Current.Session["nutterAnonymous"] = (int)System.Web.HttpContext.Current.Session["nutterAnonymous"] + score2fin;
                        }
                        else
                        {
                            System.Web.HttpContext.Current.Session["nutterAnonymous"] = score2fin;
                        }
                    }
                }
            }

            //System.Web.HttpContext.Current.User.Identity.Name
            return("Fin du jeu !");
        }
Ejemplo n.º 10
0
        public string gameend(int n1, int n2, int n3, int b, int good)
        {
            try
            {
                string valeurglobale;
                if (System.Web.HttpContext.Current.Session["idfbk"] != null)
                {
                    valeurglobale = System.Web.HttpContext.Current.Session["idfbk"] as string;
                    ViewBag.idfbk = valeurglobale;
                    if (!string.IsNullOrEmpty(valeurglobale))
                    {
                        // Si c'est un facebook user, on stocke les scores dans le modèle facebook
                        string             idfacebooker = Convert.ToString(ViewBag.idfbk);
                        AWLFacebookContext db           = new AWLFacebookContext();
                        AWLFacebookProfile user         = db.FacebookNuttersTable.FirstOrDefault(u => u.UserId.Equals(valeurglobale));
                        user.UserNuts1 = n3;
                        user.UserNuts2 = n2;
                        user.UserNuts3 = n1;
                        user.UserBonus = b;
                        user.UserLevel = good;
                        // Mise à jour des noix d'or, de bronze et simples
                        while (user.UserNuts1 > 30)
                        {
                            int restesimple = user.UserNuts1 - 30;
                            user.UserNuts2 = user.UserNuts2 + 1;
                            user.UserNuts1 = restesimple;
                        }
                        while (user.UserNuts2 > 10)
                        {
                            int restesimple2 = user.UserNuts2 - 10;
                            user.UserNuts3 = user.UserNuts3 + 1;
                            user.UserNuts2 = restesimple2;
                        }
                        db.SaveChanges();
                    }
                }
                else
                {
                    if (enregistre4)
                    {
                        // Si c'est un nutter user, on stocke les scores dans le modèle du user courant
                        UsersContext db   = new UsersContext();
                        UserProfile  user = db.UserProfiles.FirstOrDefault(u => u.UserName.Equals(System.Web.HttpContext.Current.User.Identity.Name));
                        user.UserNuts1 = n3;
                        user.UserNuts2 = n2;
                        user.UserNuts3 = n1;
                        user.UserBonus = b;
                        user.UserLevel = good;
                        // Mise à jour des noix d'or, de bronze et simples
                        while (user.UserNuts1 > 30)
                        {
                            int restesimple = user.UserNuts1 - 30;
                            user.UserNuts2 = user.UserNuts2 + 1;
                            user.UserNuts1 = restesimple;
                        }
                        while (user.UserNuts2 > 10)
                        {
                            int restesimple2 = user.UserNuts2 - 10;
                            user.UserNuts3 = user.UserNuts3 + 1;
                            user.UserNuts2 = restesimple2;
                        }
                        db.SaveChanges();
                    }
                    else
                    {
                        // On détruit la variable de session
                        if (System.Web.HttpContext.Current.Session["nutterAnonymous"] != null)
                        {
                            System.Web.HttpContext.Current.Session.Remove("nutterAnonymous");
                        }
                    }
                }

                // Retourne la position de départ des hibous
                return("OK");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 11
0
        public ActionResult Index()
        {
            string valeurglobale = string.Empty;;

            if (System.Web.HttpContext.Current.Session["idfbk"] != null)
            {
                valeurglobale = System.Web.HttpContext.Current.Session["idfbk"] as string;
                ViewBag.idfbk = valeurglobale;
            }


            if (valeurglobale != string.Empty)
            {
                // Appel vers la fonction Index de Play2
                AWLFacebookContext db   = new AWLFacebookContext();
                AWLFacebookProfile user = db.FacebookNuttersTable.FirstOrDefault(u => u.UserId.Equals(valeurglobale));
                ViewBag.awlchamplevelniveau  = 1;
                ViewBag.awlchamptopalealevel = 10;
                ViewBag.awlchampagitation    = 1000;
                ViewBag.awlchampn1           = user.UserNuts3;
                ViewBag.awlchampn2           = user.UserNuts2;
                ViewBag.awlchampn3           = user.UserNuts1;
                ViewBag.awlchampb            = user.UserBonus;


                // Récupération du niveau atteint quand on est enregistré
                ViewBag.levelreached = user.UserLevel;
            }
            else
            {
                if (enregistre3)
                {
                    // Si c'est un nutter user, on stocke les scores dans le modèle du user courant
                    UsersContext db   = new UsersContext();
                    UserProfile  user = db.UserProfiles.FirstOrDefault(u => u.UserName.Equals(System.Web.HttpContext.Current.User.Identity.Name));
                    ViewBag.awlchamplevelniveau  = 1;
                    ViewBag.awlchamptopalealevel = 10;
                    ViewBag.awlchampagitation    = 1000;
                    ViewBag.awlchampn1           = user.UserNuts3;
                    ViewBag.awlchampn2           = user.UserNuts2;
                    ViewBag.awlchampn3           = user.UserNuts1;
                    ViewBag.awlchampb            = user.UserBonus;


                    // Récupération du niveau atteint quand on est enregistré
                    ViewBag.levelreached = user.UserLevel;
                }
                else
                {
                    ViewBag.awlchamplevelniveau  = 1;
                    ViewBag.awlchamptopalealevel = 10;
                    ViewBag.awlchampagitation    = 1000;
                    ViewBag.awlchampn1           = 0;
                    ViewBag.awlchampn2           = 0;
                    ViewBag.awlchampn3           = 10;
                    ViewBag.awlchampb            = 0;

                    // Niveau atteint quand on n'est pas enregistré
                    ViewBag.levelreached = 1;
                }
            }

            return(View());
        }
        //
        // GET: /SuccessPaiementFbk/

        public ActionResult Index(string identifiant, string montant, string devise, string itemnumber, string idnutter)
        {
            AWLFacture achat = new AWLFacture(); // this is something I have defined in order to save the order in the database

            //validate the order
            string  dateNumber = DateTime.Now.ToString();
            Decimal amountPaid = 0;

            Decimal.TryParse(montant, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out amountPaid);

            AWLFacturesContext contextFactures = new AWLFacturesContext();
            List <AWLFacture>  tableFactures   = contextFactures.FacturesTable.ToList();

            if (tableFactures.Count(d => d.IdPaiement == identifiant) < 1)
            {
                //if the transactionID is not found in the database, add it
                //then, add the additional features to the user account
                AWLFacebookContext db        = new AWLFacebookContext();
                AWLFacebookProfile userBuyer = db.FacebookNuttersTable.FirstOrDefault(u => u.UserId.Equals(idnutter));


                // Mise à jour des paramètres d'achat
                achat.IdPaiement = identifiant;
                achat.Buyer      = userBuyer.UserName + "/" + idnutter;
                string nomitem;
                if (itemnumber == "1")
                {
                    achat.Article = "Simple Nuts";
                }
                else if (itemnumber == "2")
                {
                    achat.Article = "Bronze Nuts";
                }
                else if (itemnumber == "3")
                {
                    achat.Article = "Gold Nuts";
                }
                else if (itemnumber == "4")
                {
                    achat.Article = "Package Nuts";
                }

                nomitem          = achat.Article;
                achat.Montant    = amountPaid;
                achat.Plateforme = dateNumber + " - with FACEBK";

                // On ajoute l'entrée dans la table Factures et on sauve la base de données
                contextFactures.FacturesTable.Add(achat);
                contextFactures.SaveChanges();

                // Génération du PDF et des emails

                // Ajout des noix dans le compte du nutter
                if (itemnumber == "1")
                {
                    userBuyer.UserNuts1 = userBuyer.UserNuts1 + 30;
                }
                else if (itemnumber == "2")
                {
                    userBuyer.UserNuts2 = userBuyer.UserNuts2 + 30;
                }
                else if (itemnumber == "3")
                {
                    userBuyer.UserNuts3 = userBuyer.UserNuts3 + 30;
                }
                else if (itemnumber == "4")
                {
                    userBuyer.UserNuts1 = userBuyer.UserNuts1 + 30;
                    userBuyer.UserNuts2 = userBuyer.UserNuts2 + 30;
                    userBuyer.UserNuts3 = userBuyer.UserNuts3 + 30;
                }
                db.SaveChanges();

                // Mise à jour dans le panel d'en haut à droite
                ViewData["noix1"] = userBuyer.UserNuts1;
                ViewData["noix2"] = userBuyer.UserNuts2;
                ViewData["noix3"] = userBuyer.UserNuts3;

                // Pour la fenetre de confirmation et de succès
                ViewBag.nomitem         = nomitem;
                ViewBag.identifiantcool = identifiant;
                ViewBag.montantcool     = montant;
                ViewBag.devisecool      = devise;

                return(View());
            }
            else
            {
                //error
                return(View("ErrorBuy"));
            }
        }