public UtilisateurWeb Conversion(Patient patient)
        {
            if (patient == null)
            {
                throw new CompteException("Une erreur est survenu sur le patient");
            }

            return(new UtilisateurWeb()
            {
                IDWeb = patient.IDPatient,
                Adresse = patient.Adresse,
                DateNaissance = ConvertionDate.ConvertionDateTimeVersString(patient.DateNaissance),
                CreePar = patient.CreePar,
                DateCreation = patient.DateCreation,
                DernierModif = patient.DernierModif,
                Identifiant = patient.Identifiant,
                MotDePass = "",
                Nom = patient.Nom,
                Prenom = patient.Prenom,
                MesMedecin = retourMedecinAttritre(patient.MesMedecin),
                MesMigraines = patient.MesMigraines,
                MesMedicaments = patient.MesMedicaments,
                MesFacteurs = patient.MesFacteurs,
                Telephone = patient.Telephone,
                TelephonePortable = patient.TelephonePortable,
                AdresseMail = patient.AdresseMail,
                Erreur = patient.Erreur,
                Token = patient.Token,
                Type = false
            });
        }
Пример #2
0
        public Patient VoirPatient(string identifiant)
        {
            using (DataClasses1DataContext entity = new DataClasses1DataContext())
            {
                var ret = entity.T_PATIENT.Join(entity.T_COMPTE,
                                                P => P.IdCompte,
                                                C => C.ID,
                                                (P, C) => new { IDPatient = P.ID, ID = C.ID, Identifiant = C.Identifiant, Nom = C.Nom, Prenom = C.Prenom, AdresseMail = C.AdressMail, Telephone = P.TelephoneFixe, TelephonePortable = P.TelephonePortable, DateNaissance = P.DateNaissance, Token = C.Token }).Where(elt => elt.Identifiant == identifiant).FirstOrDefault();

                List <Medecin>    MesMedecins    = new MedecinDAO().ListMedecinDuPatient((int)ret.IDPatient);
                List <Migraine>   MesMigraines   = new MigraineDAO().ListeMigrainePatient((int)ret.IDPatient);
                List <Medicament> MesMedicaments = new MedicamentDAO().ListeMesMedicaments((int)ret.IDPatient);
                List <Facteur>    MesFacteurs    = new FacteurDAO().ListeFacteurPatient((int)ret.IDPatient);
                return(new Patient()
                {
                    IDPatient = ret.IDPatient, ID = (int)ret.ID, Identifiant = ret.Identifiant, MotDePass = "", Nom = ret.Nom, Prenom = ret.Prenom, AdresseMail = ret.AdresseMail, Telephone = ret.Telephone, TelephonePortable = ret.TelephonePortable, DateNaissance = ConvertionDate.ConvertionStringVersDateTime(ret.DateNaissance), MesMedecin = MesMedecins, MesMigraines = MesMigraines, MesMedicaments = MesMedicaments, MesFacteurs = MesFacteurs, Adresse = new AdresseDAO().LectureAdresse(ret.ID), Token = ret.Token
                });
            }
        }
Пример #3
0
        /// <summary>
        /// Modification des informations du Patient
        /// </summary>
        /// <param name="IdPatient"></param>
        /// <param name="Age"></param>
        /// <param name="IdMedecin"></param>
        /// <returns></returns>
        public Patient Modification(Patient patient)
        {
            using (DataClasses1DataContext entity = new DataClasses1DataContext())
            {
                //Patient patienbdd = _ListPatient.Where(elt => elt.Identifiant == patient.Identifiant).First();

                int retour = entity.ModifPatient(entity.T_PATIENT.FirstOrDefault(elt => elt.ID == patient.IDPatient).IdCompte, patient.Nom, patient.Prenom, ConvertionDate.ConvertionDateTimeVersString(DateTime.UtcNow), patient.AdresseMail, ServiceSecurite.GenererToken(patient.Identifiant, new CompteDAO().GetMotDePass(patient.Identifiant), DateTime.UtcNow.Ticks), patient.IDPatient, ConvertionDate.ConvertionDateTimeVersString(patient.DateNaissance), patient.TelephonePortable, patient.Telephone, patient.Sexe);
                if (retour == -1)
                {
                    throw new CompteModificationException(patient, "La modification du patient n'a pus avoir lieu");
                }

                //Rafraichir();
                Patient RetourPatient = VoirPatient(patient.IDPatient);
                return(RetourPatient);
            }
        }
Пример #4
0
        /// <summary>
        /// Ajoute un nouveau Patient
        /// </summary>
        /// <param name="patient"></param>
        /// <returns></returns>
        public Patient AjoutPatient(Patient patient)
        {
            using (DataClasses1DataContext entity = new DataClasses1DataContext())
            {
                //DateTime Maintenant = DateTime.Now;
                int retour = entity.AjoutPatient(patient.Identifiant, ServiceSecurite.HashMotDePass(patient.MotDePass), patient.Nom, patient.Prenom, patient.DateCreation, patient.DernierModif, 0, patient.AdresseMail, "", ConvertionDate.ConvertionDateTimeVersString(patient.DateNaissance), patient.TelephonePortable, patient.Telephone, patient.Sexe);
                if (retour == -1)
                {
                    throw new CompteException("Le compte exite déjà");
                }
                //Rafraichir();

                //Patient RetourPatient = (from elt in _ListPatient where (elt.IDPatient == retour) select elt).SingleOrDefault();
                //Patient RetourPatient = _ListPatient.SingleOrDefault(p => p.IDPatient == retour);
                Patient RetourPatient = this.VoirPatient(retour);
                RetourPatient.Adresse = new AdresseDAO().AjoutAdresse(RetourPatient.ID, patient);
                return(RetourPatient);
            }
        }
Пример #5
0
        public List <Patient> ListPatient()
        {
            using (DataClasses1DataContext entity = new DataClasses1DataContext())
            {
                var ret = entity.T_PATIENT.Join(entity.T_COMPTE,
                                                P => P.IdCompte,
                                                C => C.ID,
                                                (P, C) => new { IDPatient = P.ID, ID = C.ID, Identifiant = C.Identifiant, Nom = C.Nom, Prenom = C.Prenom, AdresseMail = C.AdressMail, Telephone = P.TelephoneFixe, TelephonePortable = P.TelephonePortable, DateNaissance = P.DateNaissance, Token = C.Token });

                List <Patient> Retour = new List <Patient>();

                foreach (var Element in ret)
                {
                    List <Medecin>    MesMedecins    = new MedecinDAO().ListMedecinDuPatient((int)Element.IDPatient);
                    List <Migraine>   MesMigraines   = new MigraineDAO().ListeMigrainePatient((int)Element.IDPatient);
                    List <Medicament> MesMedicaments = new MedicamentDAO().ListeMesMedicaments((int)Element.IDPatient);
                    List <Facteur>    MesFacteurs    = new FacteurDAO().ListeFacteurPatient((int)Element.IDPatient);
                    Retour.Add(new Patient()
                    {
                        IDPatient = Element.IDPatient, ID = (int)Element.ID, Identifiant = Element.Identifiant, MotDePass = "", Nom = Element.Nom, Prenom = Element.Prenom, AdresseMail = Element.AdresseMail, Telephone = Element.Telephone, TelephonePortable = Element.TelephonePortable, DateNaissance = ConvertionDate.ConvertionStringVersDateTime(Element.DateNaissance), MesMedecin = MesMedecins, MesMigraines = MesMigraines, MesMedicaments = MesMedicaments, MesFacteurs = MesFacteurs, Adresse = new AdresseDAO().LectureAdresse(Element.ID)
                    });
                }
                return(Retour);
            }
        }
Пример #6
0
        /// <summary>
        /// Modification des informations du Medecin
        /// </summary>
        /// <param name="IdMedecin"></param>
        /// <param name="Age"></param>
        /// <returns></returns>
        public Medecin Modification(Medecin medecin)
        {
            using (DataClasses1DataContext entity = new DataClasses1DataContext())
            {
                //Medecin medecinbdd = _ListMedecin.Where(elt => elt.Identifiant == medecin.Identifiant).SingleOrDefault();
                //Medecin medecinbdd = VoirMedecin(medecin.Identifiant);
                int retour = entity.ModifMedecin(entity.T_MEDECIN.FirstOrDefault(elt => elt.ID == medecin.IDMedecin).IdCompte, medecin.Nom, medecin.Prenom, ConvertionDate.ConvertionDateTimeVersString(DateTime.UtcNow), medecin.AdresseMail, ServiceSecurite.GenererToken(medecin.Identifiant, new CompteDAO().GetMotDePass(medecin.Identifiant), DateTime.UtcNow.Ticks), (int)medecin.IDMedecin, medecin.Telephone, medecin.InfoComplementaire);
                if (retour == -1)
                {
                    throw new CompteModificationException(medecin, "La modification du medecin n'a pus avoir lieu");
                }

                Medecin RetourMedecin = this.VoirMedecin(retour);
                RetourMedecin.Adresse          = new AdresseDAO().AjoutAdresse(RetourMedecin.ID, medecin);
                RetourMedecin.HoraireOuverture = new HoraireDAO().AjoutHoraire(retour, medecin.HoraireOuverture);

                return(RetourMedecin);
                //if (AdresseRetour == null) throw new CompteModificationException(medecin, "La modification du medecin n'a pus avoir lieu");
                //if (HoraireRetour.Length == 0) throw new CompteModificationException(medecin, "La modification du medecin n'a pus avoir lieu");



                //Rafraichir();

                //RetourMedecin.HoraireOuverture = new HoraireDAO().AjoutHoraire(retour, medecin.HoraireOuverture);
                //RetourMedecin.Adresse = new AdresseDAO().AjoutAdresse(RetourMedecin.ID, medecin);
                //Rafraichir();

                //return _ListMedecin.Where(Id => Id.IDMedecin == retour).First();
            }
        }
Пример #7
0
        /// <summary>
        /// Ajout, dans la based d'un nouveau Medecin
        /// </summary>
        /// <param name="patient"></param>
        /// <returns></returns>
        public Medecin AjoutMedecin(Medecin medecin)
        {
            using (DataClasses1DataContext entity = new DataClasses1DataContext())
            {
                int retour = entity.AjoutMedecin(medecin.Identifiant, ServiceSecurite.HashMotDePass(medecin.MotDePass), medecin.Nom, medecin.Prenom, ConvertionDate.ConvertionDateTimeVersString(DateTime.Now), ConvertionDate.ConvertionDateTimeVersString(DateTime.Now), 0, medecin.AdresseMail, "", medecin.Telephone, medecin.InfoComplementaire);
                if (retour == -1)
                {
                    throw new CompteException("Le compte exite déjà");
                }

                //Rafraichir();
                //Medecin RetourMedecin = _ListMedecin.Where(Id => Id.IDMedecin == retour).SingleOrDefault();
                //Medecin RetourMedecin =
                Medecin RetourMedecin = this.VoirMedecin(retour);
                RetourMedecin.HoraireOuverture = new HoraireDAO().AjoutHoraire(retour, medecin.HoraireOuverture);
                RetourMedecin.Adresse          = new AdresseDAO().AjoutAdresse(RetourMedecin.ID, medecin);


                return(VoirMedecin(retour));
            }
        }
Пример #8
0
        //public static TokenValide(string tokenlongue)
        //{
        //    IsTokenValid(tokenlongue);
        //}

        /// <summary>
        /// Transforme l'UtilisateurWeb en un Patient ou un Medecin. Retourne un compte
        /// </summary>
        /// <param name="compteWeb"></param>
        /// <returns></returns>
        public static Compte UtilisateurWebVersCompte(UtilisateurWeb compteWeb)
        {
            if (compteWeb.IDWeb == 0) //S'il s'agit d'un nouveau compte.
            {
                if (compteWeb.Type)
                {
                    Medecin CompteMedecin = new Medecin();
                    CompteMedecin.IDMedecin          = compteWeb.IDWeb;
                    CompteMedecin.InfoComplementaire = compteWeb.InfoComplementaire;
                    CompteMedecin.Adresse            = compteWeb.Adresse;
                    CompteMedecin.CreePar            = compteWeb.CreePar;
                    CompteMedecin.DateCreation       = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now);
                    CompteMedecin.DernierModif       = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now);
                    CompteMedecin.Identifiant        = compteWeb.Identifiant;
                    CompteMedecin.MotDePass          = compteWeb.MotDePass;
                    CompteMedecin.Nom              = compteWeb.Nom;
                    CompteMedecin.Prenom           = compteWeb.Prenom;
                    CompteMedecin.Telephone        = compteWeb.Telephone;
                    CompteMedecin.AdresseMail      = compteWeb.AdresseMail;
                    CompteMedecin.HoraireOuverture = compteWeb.HoraireOuverture;
                    CompteMedecin.Token            = compteWeb.Token;
                    return(CompteMedecin);
                }
                else
                {
                    Patient retourPatient = new Patient();
                    retourPatient.IDPatient         = compteWeb.IDWeb;
                    retourPatient.Adresse           = compteWeb.Adresse;
                    retourPatient.CreePar           = compteWeb.CreePar;
                    retourPatient.DateCreation      = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now);
                    retourPatient.DateNaissance     = ConvertionDate.ConvertionStringVersDateTime(compteWeb.DateNaissance);
                    retourPatient.DernierModif      = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now);
                    retourPatient.Identifiant       = compteWeb.Identifiant;
                    retourPatient.MesMedecin        = null;
                    retourPatient.MotDePass         = compteWeb.MotDePass;
                    retourPatient.Nom               = compteWeb.Nom;
                    retourPatient.Prenom            = compteWeb.Prenom;
                    retourPatient.Sexe              = compteWeb.Sexe;
                    retourPatient.Telephone         = compteWeb.Telephone;
                    retourPatient.TelephonePortable = compteWeb.TelephonePortable;
                    retourPatient.AdresseMail       = compteWeb.AdresseMail;
                    retourPatient.Token             = compteWeb.Token;
                    return(retourPatient);
                }
            }
            if (new MedecinDAO().IsMedecin(compteWeb.IDWeb)) // si le compte en création est un Medecin
            {
                Medecin CompteMedecin = new Medecin();
                CompteMedecin.IDMedecin          = compteWeb.IDWeb;
                CompteMedecin.InfoComplementaire = compteWeb.InfoComplementaire;
                CompteMedecin.Adresse            = compteWeb.Adresse;
                CompteMedecin.CreePar            = compteWeb.CreePar;
                CompteMedecin.DateCreation       = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now);
                CompteMedecin.DernierModif       = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now);
                CompteMedecin.Identifiant        = compteWeb.Identifiant;
                CompteMedecin.MotDePass          = compteWeb.MotDePass;
                CompteMedecin.Nom              = compteWeb.Nom;
                CompteMedecin.Prenom           = compteWeb.Prenom;
                CompteMedecin.Telephone        = compteWeb.Telephone;
                CompteMedecin.AdresseMail      = compteWeb.AdresseMail;
                CompteMedecin.HoraireOuverture = compteWeb.HoraireOuverture;
                CompteMedecin.Token            = compteWeb.Token;
                return(CompteMedecin);
            }
            if (new PatientDAO().IsPatient(compteWeb.IDWeb)) // si le compte en création est un Patient
            {
                Patient retourPatient = new Patient();
                retourPatient.IDPatient         = compteWeb.IDWeb;
                retourPatient.Adresse           = compteWeb.Adresse;
                retourPatient.CreePar           = compteWeb.CreePar;
                retourPatient.DateCreation      = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now);
                retourPatient.DateNaissance     = ConvertionDate.ConvertionStringVersDateTime(compteWeb.DateNaissance);
                retourPatient.DernierModif      = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now);
                retourPatient.Identifiant       = compteWeb.Identifiant;
                retourPatient.MesMedecin        = null;
                retourPatient.MotDePass         = compteWeb.MotDePass;
                retourPatient.Nom               = compteWeb.Nom;
                retourPatient.Prenom            = compteWeb.Prenom;
                retourPatient.Sexe              = compteWeb.Sexe;
                retourPatient.Telephone         = compteWeb.Telephone;
                retourPatient.TelephonePortable = compteWeb.TelephonePortable;
                retourPatient.AdresseMail       = compteWeb.AdresseMail;
                retourPatient.Token             = compteWeb.Token;

                return(retourPatient);
            }
            else
            {
                throw new UtilisateurWebInexistantException("Ce compte n'existe pas", compteWeb);
            }
        }