Example #1
0
        public static Response SendMail(string identification, string condition = "Roja")
        {
            try
            {
                string causes   = string.Empty;
                string strEmail = System.IO.File.ReadAllText(@"..\AITestBackend\Util\EmailTemplate.html");
                var    Patient  = PatientModel.GetPatient(identification).Patient;
                var    Parent   = ParentModel.GetParent(Patient.IdParent).Parent;

                if (PatientCaseModel.GetAllPatientCases(Patient.Identification) != null &&
                    PatientCaseModel.GetAllPatientCases(Patient.Identification).IsSuccessful&&
                    PatientCaseModel.GetAllPatientCases(Patient.Identification).PatientCases.Count() > 0)
                {
                    causes = PatientCaseModel.GetAllPatientCases(Patient.Identification).PatientCases[0].Procesed_Data;
                }

                //string path = Server.MapPath($"~/EmailTemplate/index.html");



                strEmail = strEmail.Replace("[Nombre del Encargado]", Parent.Name).Replace("[NombreDelPaciente]", Patient.Name).Replace("[NumeroCedula]", Parent.Identification).Replace("[CondicionPaciente]", condition).Replace("[SintomasPaciente]", causes);


                //AlternateView htmlView = AlternateView.CreateAlternateViewFromString(strEmail, System.Text.Encoding.UTF8, "text/html");
                MailMessage correo = new MailMessage("*****@*****.**", "*****@*****.**");

                //   Agregar vista a email
                //correo.AlternateViews.Add(htmlView);
                correo.Subject    = "Prueba Send Mail Programathon";
                correo.IsBodyHtml = true;
                correo.Priority   = MailPriority.Normal;
                correo.Body       = strEmail;

                // mail to

                //   Set SMTP Client;
                SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587)
                {
                    UseDefaultCredentials = false,
                    EnableSsl             = true,
                    Credentials           = new System.Net.NetworkCredential(AppManagement.emailUser, AppManagement.emailPass),
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                };

                smtp.Send(correo);

                return(new Response {
                    IsSuccessful = true, ResponseMessage = "Enviado Exitosamente!"
                });;
            }
            catch (Exception ex)
            {
                return(new Response {
                    IsSuccessful = false, ResponseMessage = ex.Message
                });
            }
        }
Example #2
0
        public static ResponsePatient GetPatient(string identification)
        {
            PatientModel patient = null;

            using (MySqlConnection conn = ConecctionModel.conn)
            {
                conn.Open();
                string       SP  = AppManagement.SP_GetPatient;
                MySqlCommand cmd = new MySqlCommand(SP, conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@p_id_patient", identification);

                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        patient = new PatientModel()
                        {
                            Identification = rdr["id_patient"].ToString(),
                            IdParent       = rdr["id_parent"].ToString(),
                            Name           = rdr["name"].ToString(),
                            BirthDate      = Convert.ToDateTime(rdr["birth_date"]),
                            Age            = Convert.ToInt32(rdr["age"]),
                            Ethnic         = new EthnicModel()
                            {
                                Id   = Convert.ToInt32(rdr["id_ethnic_group"]),
                                Name = rdr["ethnic_name"].ToString()
                            },
                            Gender = rdr["gender"].ToString()
                        };
                    }
                }
            }

            if (patient.IsNotNull())
            {
                patient.Treatments = PatientTreatmentDeseaseModel.GetAllTreatmentDeseasest(patient.Identification).PatientTreatmentDeseases;


                patient.Attachments = AttachmentsModel.GetAllAttachments(patient.Identification).ResponseAttachments;

                patient.Cases = PatientCaseModel.GetAllPatientCases(patient.Identification).PatientCases;
            }

            return(new ResponsePatient {
                IsSuccessful = true, ResponseMessage = AppManagement.MSG_GetPatient_Success, Patient = patient
            });
        }