Example #1
0
        public ActionResult Accept(int id)
        {
            var StepReq = ssr.GetById(id);

            if (StepReq.Type == "Add")
            {
                Step step = new Step();
                step.StepDate             = StepReq.NewStepDate;
                step.StepDescription      = StepReq.NewStepDescription;
                step.StepSpeciality       = StepReq.NewStepSpeciality;
                step.TreatmentId          = StepReq.NewTreatmentId;
                step.Validation           = false;
                step.NbModifications      = 0;
                step.LastModificationBy   = StepReq.NewLastModificationBy;
                step.LastModificationDate = StepReq.NewLastModificationDate;
                step.ModificationReason   = "No modifications yet";
                ss.Add(step);
                ss.Commit();
                ssr.Delete(StepReq);
                ssr.Commit();
            }
            else if (StepReq.Type == "Update")
            {
                Step step = ss.GetById(StepReq.StepId);
                step.StepDate             = StepReq.NewStepDate;
                step.StepDescription      = StepReq.NewStepDescription;
                step.StepSpeciality       = StepReq.NewStepSpeciality;
                step.TreatmentId          = StepReq.NewTreatmentId;
                step.Validation           = StepReq.NewValidation;
                step.NbModifications     += 1;
                step.LastModificationBy   = StepReq.NewLastModificationBy;
                step.LastModificationDate = StepReq.NewLastModificationDate;
                step.ModificationReason   = StepReq.NewModificationReason;
                ss.Update(step);
                ss.Commit();
                ssr.Delete(StepReq);
                ssr.Commit();
            }

            return(Redirect(Request.UrlReferrer.ToString()));
        }
Example #2
0
        public ActionResult Create(int id, StepViewModel collection)
        {
            TempData["idPatient"]   = st.GetById(id).PatientId;
            TempData["idTreatment"] = id;
            try
            {
                var docteurreferant = st.GetById(id).DoctorId;
                if (Int32.Parse(User.Identity.GetUserId()) == docteurreferant)
                {
                    Step s = new Step();
                    s.TreatmentId = id;

                    s.LastModificationBy   = Int32.Parse(User.Identity.GetUserId());
                    s.LastModificationDate = DateTime.UtcNow.Date;
                    s.ModificationReason   = "No modifications yet";
                    s.StepDate             = collection.StepDate;
                    s.StepDescription      = collection.StepDescription;
                    s.StepSpeciality       = collection.StepSpeciality;
                    s.Appointment          = null;
                    s.NbModifications      = 0;

                    s.Validation = false;

                    ss.Add(s);
                    ss.Commit();
                }
                else
                {
                    StepRequest sr = new StepRequest();
                    sr.NewTreatmentId = id;

                    sr.NewLastModificationBy   = Int32.Parse(User.Identity.GetUserId());
                    sr.NewLastModificationDate = DateTime.UtcNow.Date;
                    sr.NewModificationReason   = "No modifications yet";
                    sr.NewStepDate             = collection.StepDate;
                    sr.NewStepDescription      = collection.StepDescription;
                    sr.NewStepSpeciality       = collection.StepSpeciality;
                    sr.StepId        = 0;
                    sr.Type          = "Add";
                    sr.NewValidation = false;
                    ssr.Add(sr);
                    ssr.Commit();
                    var maildocteur     = us.GetUserById(st.GetById(sr.NewTreatmentId).DoctorId).Email;
                    var mailpatient     = us.GetUserById(st.GetById(sr.NewTreatmentId).PatientId).Email;
                    var lastmodifbyname = us.GetUserById(Int32.Parse(User.Identity.GetUserId())).FirstName + " " + us.GetUserById(Int32.Parse(User.Identity.GetUserId())).LastName;
                    var illness         = st.GetById(sr.NewTreatmentId).Illness;
                    var patient         = us.GetUserById(st.GetById(sr.NewTreatmentId).PatientId).FirstName + " " + us.GetUserById(st.GetById(sr.NewTreatmentId).PatientId).LastName;
                    //MAIL
                    MailMessage mail = new MailMessage("*****@*****.**", maildocteur, "New step request", "The doctor '" + lastmodifbyname + "' sent a request to add a new step in the treatment of '" + illness + "' of the patient '" + patient + "'");
                    mail.IsBodyHtml = true;
                    SmtpClient smtpClient = new SmtpClient("Smtp.gmail.com", 587);
                    smtpClient.EnableSsl = true;

                    smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "epionepidev123");
                    smtpClient.Send(mail);
                    //!MAIL
                }
                return(RedirectToAction("Details", "Treatment", new { id = id }));
            }
            catch
            {
                return(View());
            }
        }