// GET: MedicalPath/Delete/5
        public ActionResult Delete(int id)
        {
            MedicalPath MedicalPaths = sm.GetMany().Single(s => s.MedicalPathId == id);



            return(View(MedicalPaths));
        }
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                MedicalPath MedicalPaths = sm.GetMany().Single(s => s.MedicalPathId == id);
                sm.Delete(MedicalPaths);
                sm.Commit();
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(MedicalPathModels pm)
        {
            try
            {
                MedicalPath p = new MedicalPath()
                {
                    SpecialityId = pm.SpecialityId,
                    Description  = pm.Description,
                    UserId       = pm.UserId,
                    DateParcour  = pm.DateParcour,
                    DoctorId     = pm.DoctorId,
                };
                // TODO: Add insert logic here
                sm.Add(p);
                sm.Commit();
                /****Mail****/

                try
                {
                    MailMessage message = new MailMessage("*****@*****.**", "*****@*****.**", "Parcour ", "Il faut avoir un autre specialiste");
                    message.IsBodyHtml = true;
                    SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                    client.EnableSsl   = true;
                    client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "amine44108329");
                    client.Send(message);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                /****Mail****/



                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(int id, MedicalPath newMedicalPath)
        {
            try
            {
                // TODO: Add update logic here
                MedicalPath oldMedicalPath = sm.GetMany().Single(s => s.MedicalPathId == id);
                oldMedicalPath.SpecialityId = newMedicalPath.SpecialityId;
                oldMedicalPath.Description  = newMedicalPath.Description;
                oldMedicalPath.UserId       = newMedicalPath.UserId;
                oldMedicalPath.DateParcour  = newMedicalPath.DateParcour;
                oldMedicalPath.DoctorId     = newMedicalPath.DoctorId;
                // oldMedicalPath.AdresseDotor = newMedicalPath.AdresseDotor;

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }