예제 #1
0
 public void Add(Exploitation exp)
 {
     if (isValid(exp))
     {
         _QueryDao.Insert(exp);
     }
 }
예제 #2
0
 private bool isValid(Exploitation exp)
 {
     return(_GouvProxy.CheckSiretExisteGouvernementApi(exp) &&
            validationSiret(exp) &&
            validationNom(exp) &&
            validationRaisonSociale(exp));
 }
예제 #3
0
 public void Update(Exploitation exp)
 {
     if (isValid(exp))
     {
         _QueryDao.Update(exp);
     }
 }
예제 #4
0
        private bool validationNom(Exploitation exp)
        {
            // validation name
            if (string.IsNullOrWhiteSpace(exp.Nom))
            {
                return(false);
            }

            return(true);
        }
예제 #5
0
        private bool validationRaisonSociale(Exploitation exp)
        {
            // validation name
            if (string.IsNullOrWhiteSpace(exp.RaisonSociale))
            {
                return(false);
            }

            return(true);
        }
예제 #6
0
        public bool CheckSiretExisteGouvernementApi(Exploitation exp)
        {
            var result = _HttpClient.PostAsync("http://api.gouv.fr/siret/exist", new StringContent(exp.Siret)).Result;

            if (result.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
예제 #7
0
        public void Delete(Exploitation exp)
        {
            this._Connection.Open();

            // Création d'une commande SQL en fonction de l'objet connection
            MySqlCommand cmd = this._Connection.CreateCommand();

            // DELETE FROM Exploitation
            // WHERE .....
        }
예제 #8
0
        public void Update(Exploitation exp)
        {
            this._Connection.Open();

            // Création d'une commande SQL en fonction de l'objet connection
            MySqlCommand cmd = this._Connection.CreateCommand();

            // UPDATE Exploitation
            // SET .........
        }
예제 #9
0
        public void Insert(Exploitation exp)
        {
            this._Connection.Open();

            // Création d'une commande SQL en fonction de l'objet connection
            MySqlCommand cmd = this._Connection.CreateCommand();
            // INSERT INTO Exploitation
            // (............)
            // VALUES
            // (............)
        }
예제 #10
0
        private bool validationSiret(Exploitation exp)
        {
            // validation siret
            // verification not nulle
            if (string.IsNullOrWhiteSpace(exp.Siret))
            {
                return(false);
            }
            // verification longueur 14
            //if (societe.Siret.Count() != 14)
            //{
            //    throw new BusinessException(BusinessExceptionCode.NO_VALIDE_SIRET, "Le numéro Siret est non valide");
            //}
            // verification int
            if (!Int64.TryParse(exp.Siret, out Int64 res))
            {
                return(false);
            }
            // Validation de Luhn
            int total = 0;
            int digit = 0;

            for (int i = 0; i < exp.Siret.Length; i++)
            {
                /** Recherche les positions impaires : 1er, 3è, 5è, etc... que l'on multiplie par 2
                 * petite différence avec la définition ci-dessus car ici on travail de gauche à droite */

                if ((i % 2) == 0)
                {
                    digit = int.Parse(exp.Siret[i].ToString()) * 2;

                    /** si le résultat est >9 alors il est composé de deux digits tous les digits devant
                     * s'additionner et ne pouvant être >19 le calcule devient : 1 + (digit -10) ou : digit - 9 */

                    if (digit > 9)
                    {
                        digit -= 9;
                    }
                }
                else
                {
                    digit = int.Parse(exp.Siret[i].ToString());
                }
                total += digit;
            }

            /** Si la somme est un multiple de 10 alors le SIRET est valide */
            if ((total % 10) != 0)
            {
                return(false);
            }
            return(true);
        }
예제 #11
0
 public void Remove(Exploitation exp)
 {
     _QueryDao.Delete(exp);
 }