Beispiel #1
0
        private void SavePari(Res response, int id, StructPari value)
        {
            SqlConnection connection = Models.Connexion.Get("Server=localhost;Database=foot;User ID=sa;Password=itu;");

            Models.PariDAO       padao  = new Models.PariDAO(connection);
            Models.PariDetailDAO paddao = new Models.PariDetailDAO(connection);
            Models.ClientDAO     cldao  = new Models.ClientDAO(connection);

            Models.Pari       pari   = new Models.Pari(value.pari); pari.Id = padao.NextId();
            Models.PariDetail detail = new Models.PariDetail(value.detail); detail.Id = paddao.NextId(); detail.Pari = pari;
            Models.Client     client = cldao.SelectOne("WHERE id='" + pari.Client + "'");
            client.Solde -= detail.Montant;

            if (client != null && padao.Insert(pari.ToInsert()) > 0)
            {
                paddao.Insert(detail.ToInsert());
                cldao.Update(client);
                value.pari.id   = pari.Id;
                value.detail.id = detail.Id;
                response.data   = value;
                response.error  = false;
            }
            else
            {
                throw new Exception("Enregistrement du pari impossible !");
            }
        }
Beispiel #2
0
        private void Interessants(Res response, Pari value)
        {
            SqlConnection connection = Models.Connexion.Get("Server=localhost;Database=foot;User ID=sa;Password=itu;");

            Models.PariDetailDAO paddao = new Models.PariDetailDAO(connection);
            Models.PariDetail    detail = paddao.SelectOne("WHERE pari='" + value.id + "'");
            response.data  = paddao.Select(", Pari p WHERE p.id=pd.pari AND p.partie='" + detail.Pari.Partie + "' AND p.client != '" + detail.Pari.Client + "' AND p.typePari=" + detail.Pari.TypePari + " AND p.action='" + detail.Pari.Action + "' AND p.equilibre=" + detail.Pari.Equilibre + " AND pd.equipe!='" + detail.Equipe + "' AND pd.montant > 0");
            response.error = false;
        }
Beispiel #3
0
        private void AnswerPost(Res response, Pari value)
        {
            paddao = new Models.PariDetailDAO(connection);
            jodao  = new Models.JonctionDAO(connection);

            Models.PariDetail detail = paddao.SelectOne("WHERE pari='" + value.id + "'");
            response.data  = jodao.Select("WHERE pari='" + detail + "' OR contrePari='" + detail + "'");
            response.error = false;
        }
Beispiel #4
0
        private void ManagePut(Res response, Models.PariDetail pari, Models.PariDetail contre)
        {
            float montant = -1;

            if (pari.Montant > contre.Montant)
            {
                montant = contre.Montant;
            }
            else
            {
                montant = pari.Montant;
            }
            Models.Jonction jonct = new Models.Jonction(jodao.NextId(), pari, contre, montant, 0);
            float           pMont = pari.Montant - montant, cMont = contre.Montant - montant;

            if (pMont >= 0)
            {
                pari.Montant = pMont;
            }
            else
            {
                pari.Montant = 0;
            }
            if (cMont >= 0)
            {
                contre.Montant = cMont;
            }
            else
            {
                contre.Montant = 0;
            }

            if (pari.Pari.Equilibre == 0)
            {
                Models.Client cl1 = pari.Pari.Client; Models.Client cl2 = contre.Pari.Client;
                cl1.Solde += pari.Montant; pari.Montant = 0; cl2.Solde += contre.Montant; contre.Montant = 0;
                Models.ClientDAO cldao = new Models.ClientDAO(connection);
                cldao.Update(cl1); cldao.Update(cl2);
            }
            paddao.Update(pari); paddao.Update(contre); jodao.Insert(jonct.ToInsert());

            response.data = new Jonction()
            {
                id = jonct.Id, pari = pari.Id, contrePari = contre.Id, montant = jonct.Montant
            };
            response.error = false;
        }
Beispiel #5
0
        private void AnswerPut(Res response, int id, Jonction value)
        {
            paddao = new Models.PariDetailDAO(connection);
            jodao  = new Models.JonctionDAO(connection);

            Models.PariDetail pari   = paddao.SelectOne("WHERE pari='" + value.pari + "'");
            Models.PariDetail contre = paddao.SelectOne("WHERE pari='" + value.contrePari + "'");

            if (pari != null && contre != null)
            {
                this.ManagePut(response, pari, contre);
            }
            else
            {
                throw new Exception("Pari introuvable !");
            }
        }