Esempio n. 1
0
        public ActionResult Create([Bind(Include = "ID_Adresse,pays,ville,prefecture,village,dateDebut,dateFin,ID_Patient,ID_Staff")] Adresse adresse)
        {
            if (ModelState.IsValid)
            {
                db.Adresses.Add(adresse);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID_Patient = new SelectList(db.Patients, "ID_Patient", "createBy", adresse.ID_Patient);
            ViewBag.ID_Staff   = new SelectList(db.Staffs, "ID_Staff", "createBy", adresse.ID_Staff);
            return(View(adresse));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "ID_Staff,createDate,createBy,changeDate,changeBy,nom,prenom,sexe,role,phone,email,login,password,statut,debutService,finService")] Staff staff)
        {
            Adresse adress = new Adresse();

            if (ModelState.IsValid)
            {
                staff.createDate = DateTime.Now;

                //---------------------------------------------------------- https://stackoverflow.com/questions/22246538/access-claim-values-in-controller-in-mvc-5
                //Get the current claims principal
                var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;

                // Get the claims values
                var name = identity.Claims.Where(c => c.Type == ClaimTypes.Name)
                           .Select(c => c.Value).SingleOrDefault();
                var uid = identity.Claims.Where(c => c.Type == ClaimTypes.Sid)
                          .Select(c => c.Value).SingleOrDefault();
                var role = identity.Claims.Where(c => c.Type == ClaimTypes.Role)
                           .Select(c => c.Value).SingleOrDefault();
                //-----------------------------------------------------------------
                staff.createBy = name + " - ID: " + uid + " - Role:" + role;

                db.Staffs.Add(staff);
                string pays       = Request["country"].ToString() == "-1" ?  null : Request["country"].ToString();
                string ville      = Request["state"].ToString();
                string prefecture = Request["adress.prefecture"].ToString();
                string village    = Request["adress.village"].ToString();
                if (!string.IsNullOrEmpty(pays) || !string.IsNullOrEmpty(ville) || !string.IsNullOrEmpty(prefecture) || !string.IsNullOrEmpty(village))
                {
                    adress.ID_Staff   = staff.ID_Staff;
                    adress.pays       = !string.IsNullOrEmpty(pays) ? pays : "";
                    adress.ville      = !string.IsNullOrEmpty(ville) ? ville : "";
                    adress.prefecture = !string.IsNullOrEmpty(prefecture) ? prefecture : "";
                    adress.village    = !string.IsNullOrEmpty(village) ? village : "";
                    adress.dateDebut  = DateTime.Now;
                    adress.dateFin    = new DateTime(9999, 12, 31);
                    //adress.dateDebut = DateTime.Now;
                    //adress.dateFin
                    db.Adresses.Add(adress);
                }

                db.SaveChanges();
                db.Entry(staff).GetDatabaseValues();
                int id = staff.ID_Staff;
                db.Database.ExecuteSqlCommand("Update Staff set login='******'where ID_Staff = " + staff.ID_Staff);
                return(RedirectToAction("Index"));
            }

            return(View(staff));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "ID_Patient,createDate,createBy,changeDate,changeBy,nom,prenom,date_naissance,sexe,profession,situation_familial,groupe_sanguin,email,telephone,extra_info,statut")] Patient patient)
        {
            Adresse adress = new Adresse();

            if (ModelState.IsValid)
            {
                patient.createDate     = DateTime.Now;
                patient.groupe_sanguin = Request["groupe_sanguin"];
                //patient.createBy = User.Identity.Name;


                //---------------------------------------------------------- https://stackoverflow.com/questions/22246538/access-claim-values-in-controller-in-mvc-5
                //Get the current claims principal
                var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;

                // Get the claims values
                var name = identity.Claims.Where(c => c.Type == ClaimTypes.Name)
                           .Select(c => c.Value).SingleOrDefault();
                var uid = identity.Claims.Where(c => c.Type == ClaimTypes.Sid)
                          .Select(c => c.Value).SingleOrDefault();
                var role = identity.Claims.Where(c => c.Type == ClaimTypes.Role)
                           .Select(c => c.Value).SingleOrDefault();
                //-----------------------------------------------------------------
                patient.createBy = name + " - ID: " + uid + " - Role:" + role;
                db.Patients.Add(patient);
                string pays       = Request["country"].ToString() == "-1" ? null : Request["country"].ToString();
                string ville      = Request["state"].ToString();
                string prefecture = Request["prefecture"].ToString();
                string village    = Request["village"].ToString();
                if (!string.IsNullOrEmpty(pays) || !string.IsNullOrEmpty(ville) || !string.IsNullOrEmpty(prefecture) || !string.IsNullOrEmpty(village))
                {
                    adress.ID_Patient = patient.ID_Patient;
                    adress.pays       = !string.IsNullOrEmpty(pays) ? pays : "";
                    adress.ville      = !string.IsNullOrEmpty(ville) ? ville : "";
                    adress.prefecture = !string.IsNullOrEmpty(prefecture) ? prefecture : "";
                    adress.village    = !string.IsNullOrEmpty(village) ? village : "";
                    adress.dateDebut  = DateTime.Now;
                    adress.dateFin    = new DateTime(9999, 12, 31);
                    //adress.dateDebut = DateTime.Now;
                    //adress.dateFin
                    db.Adresses.Add(adress);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(patient));
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "ID_Consultation,creatieDate,createBy,changeDate,changeBy,motif,note,poids,taille,temperature,systol,diastol,diagnostique,maladie,antecedent,statut,ID_Patient,ID_Staff")] Consultation consultation)
        {
            if (ModelState.IsValid)
            {
                //---------------------------------------------------------- https://stackoverflow.com/questions/22246538/access-claim-values-in-controller-in-mvc-5
                //Get the current claims principal
                var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;

                // Get the claims values
                var name = identity.Claims.Where(c => c.Type == ClaimTypes.Name)
                           .Select(c => c.Value).SingleOrDefault();
                var uid = identity.Claims.Where(c => c.Type == ClaimTypes.Sid)
                          .Select(c => c.Value).SingleOrDefault();
                var role = identity.Claims.Where(c => c.Type == ClaimTypes.Role)
                           .Select(c => c.Value).SingleOrDefault();
                //-----------------------------------------------------------------
                Ordonnance ordonnance = new Ordonnance();
                Vaccin     vaccin     = new Vaccin();
                consultation.createBy    = name + " - ID: " + uid + " - Role:" + role;
                consultation.creatieDate = DateTime.Now;
                consultation.ID_Staff    = Int32.Parse(uid);
                consultation.ID_Patient  = Int32.Parse(Request["ID_Patient"].ToString());
                if (!string.IsNullOrEmpty(Request["medicament"].ToString()) || !string.IsNullOrEmpty(Request["prescription"].ToString()))
                {
                    ordonnance.medicament      = Request["medicament"].ToString();
                    ordonnance.prescription    = Request["prescription"].ToString();
                    ordonnance.ID_Consultation = consultation.ID_Consultation;
                    db.Ordonnances.Add(ordonnance);
                }

                if (string.IsNullOrEmpty(Request["vac"].ToString()))
                {
                    vaccin.date            = DateTime.Now;
                    vaccin.description     = Request["vac"].ToString();
                    vaccin.ID_Consultation = consultation.ID_Consultation;
                    db.Vaccins.Add(vaccin);
                }
                db.Consultations.Add(consultation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(consultation));
        }