Ejemplo n.º 1
0
        public static bool AjouterContactAPI(ContactEntity.User user, System.Collections.Specialized.IOrderedDictionary newValues)
        {
            ContactEntity.Contact c = new ContactEntity.Contact();

            Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user));

            c.setIdcontact(0);
            c.setIduser(template.getIduser());
            c.setDtcreation(DateTime.Now);
            c.setFavoris(false);
            c.setActif(true);

            if (c != null)
            {
                List <ContactEntity.Donnee> donnees = SetListeDonnees(newValues);

                c.setIduser(user.getIduser());
                c.setDtcreation(DateTime.Now);
                c.setFavoris(false);
                c.setActif(true);
                c.setDonnees(donnees);

                c.setIduser(user.getIduser());
                ContactWrapper cw = new ContactWrapper();
                cw.setContact(c);
                cw.setIdtemplate(template.getIdtemplate());
                ApiContact.SetContact(cw);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static ContactEntity.User GetUser(string login, string password)
        {
            ContactEntity.User u = null;
            string             strJson;

            strJson = ContactClasse.ApiContact.GetStringJSonUser(login, password);
            u       = ContactClasse.GestionContacts.GetUser(strJson);
            return(u);
        }
Ejemplo n.º 3
0
        public static void SaveContactAPI(ContactEntity.User user, System.Collections.Specialized.IOrderedDictionary oldValues, System.Collections.Specialized.IOrderedDictionary newValues)
        {
            if (user == null)
            {
                return;
            }

            //charge la liste des contacts par l'API
            string strJson = ContactClasse.ApiContact.GetStringJSonContacts(user);
            List <ContactEntity.Contact> ListeContacts = ContactClasse.GestionContacts.GetContacts(strJson);
            List <EvalEntity.Champ>      listeChamp    = dao.DaoChamp.GetChamps();

            int idcontact = 0;

            if (oldValues != null)
            {
                idcontact = Int32.Parse(oldValues["idcontact"] as string);
            }

            Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user));

            if (template != null && ListeContacts != null)
            {
                ContactEntity.Contact c = ListeContacts.Where(x => x.getIdcontact() == idcontact).FirstOrDefault();

                if (c != null)
                {
                    List <ContactEntity.Donnee> donnees = SetListeDonnees(newValues);

                    c.setIduser(user.getIduser());
                    c.setDtcreation(DateTime.Now);
                    c.setFavoris(false);
                    c.setActif(true);
                    c.setDonnees(donnees);

                    c.setIduser(user.getIduser());
                    ContactWrapper cw = new ContactWrapper();
                    cw.setContact(c);
                    cw.setIdtemplate(template.getIdtemplate());
                    ApiContact.SetContact(cw);
                }
            }
        }
Ejemplo n.º 4
0
        public static List <EvalEntity.Donnee> ChagerListeContacts(ContactEntity.User user)
        {
            string strJson = ContactClasse.ApiContact.GetStringJSonContacts(user);
            List <ContactEntity.Contact> ListeContacts = ContactClasse.GestionContacts.GetContacts(strJson);
            List <EvalEntity.Donnee>     liste         = new List <EvalEntity.Donnee>();

            Dictionary <int, EvalEntity.Champ> listeChamp = new Dictionary <int, EvalEntity.Champ>();

            foreach (ContactEntity.Contact c in ListeContacts)
            {
                foreach (ContactEntity.Donnee cd in c.getDonnees())
                {
                    EvalEntity.Donnee d = new EvalEntity.Donnee()
                    {
                        iduser       = (int)c.getIduser(),
                        iddonnee     = (int)cd.getIddonnee(),
                        idcontact    = (int)c.getIdcontact(),
                        libelleChamp = cd.getLibellechamp(),
                        valeur       = cd.getValeur(),
                        ordre        = (int)cd.getOrdre(),
                        accueil      = cd.isAccueil()
                    };
                    liste.Add(d);

                    //remplit la liste des champs
                    if (!listeChamp.ContainsKey((int)cd.getIdchamp()))
                    {
                        listeChamp.Add((int)cd.getIdchamp(), new EvalEntity.Champ()
                        {
                            idchamp = (int)cd.getIdchamp(), libelle = cd.getLibellechamp()
                        });
                    }
                }
            }

            //enregitre les champs dans la table locale, pour gestion des mises à jours
            dao.DaoChamp.saveChamps(listeChamp.Values.ToList());

            return(liste);
        }