예제 #1
0
        //public void sendSMS()
        //{

        //}

        public void sendNotification()
        {
            //PatientBusiness pb = new PatientBusiness();
            //BookingBusiness bb = new BookingBusiness();
            Booking                b   = new Booking();
            Notification           n   = new Notification();
            bookingPatient         bp  = new bookingPatient();
            Email_serviceViewModel es  = new Email_serviceViewModel();
            Email_serviceBusiness  esb = new Email_serviceBusiness();

            //var booknotif= bb.GetAllBookings();
            var brepo = new BookingRepository();

            foreach (Booking p in brepo.GetAll())
            {
                int day   = Convert.ToDateTime(p.Time_start).Date.Day;
                int month = Convert.ToDateTime(p.Time_start).Date.Month;
                int year  = Convert.ToDateTime(p.Time_start).Date.Year;
                if (p.notificationStatus != true)
                {
                    if (month == DateTime.Now.Month && year == DateTime.Now.Year)
                    {
                        if (day - 1 == Convert.ToInt32(DateTime.Now.Day))
                        {
                            es.To      = p.Email;
                            es.Subject = "Reminder";
                            es.Body    = "Good day dear " + p.PatientFullName + "<br/>" + "We want to remind you that you have an appointement tomorrow at " + p.Time + " at Glenwood Medical Centre";
                            esb.createemail(es);
                        }
                    }
                    p.notificationStatus = true;
                    brepo.Update(p);
                }
            }
        }
        public void CreateMethod(PatientModel rm, string Gender, string Status, string Title, string Patient_No)
        {
            Email_serviceViewModel es  = new Email_serviceViewModel();
            Email_serviceBusiness  esb = new Email_serviceBusiness();

            using (var parepo = new PatientRepository())
            {
                //if (rm.userId == null)
                //{
                //string result = objRegisterModel.DOB.Substring(6);
                int birthyear   = Convert.ToDateTime(rm.DOB).Year;
                int currentyear = DateTime.Now.Year;

                //int age = currentyear - Convert.ToInt32(result);
                int Yourage = currentyear - birthyear;

                Patient _patient = new Patient();

                _patient.PatientId     = rm.userId;
                _patient.Email         = rm.Email;
                _patient.FullName      = rm.FullName;
                _patient.Surname       = rm.Surname;
                _patient.Title         = Title;
                _patient.Age           = Convert.ToString(Yourage);
                _patient.MaritalStatus = Status;
                _patient.DOB           = rm.DOB;
                _patient.Sex           = Gender;
                List <string> list = new List <string>();
                foreach (PatientAddressModel pa in rm.PatientAddresses.ToList())
                {
                    if (pa.DeleteAddress == true)
                    {
                        // Delete address which is marked to remove
                        rm.PatientAddresses.Remove(pa);
                    }
                }
                ;

                foreach (var item in rm.PatientAddresses.ToList())
                {
                    PatientAddress padd = new PatientAddress();
                    padd.Address = item.Address;
                    _patient.PatientAddresses.Add(padd);
                }

                _patient.Address1          = rm.Address1;
                _patient.Address2          = rm.Address2;
                _patient.Address3          = rm.Address3;
                _patient.PostalCode        = rm.PostalCode;
                _patient.Telephone         = rm.Telephone;
                _patient.Employer          = rm.Employer;
                _patient.EmployerTelephone = rm.EmployerTelephone;
                _patient.Occupation        = rm.Occupation;
                _patient.NationalId        = rm.NationalId;
                _patient.Status            = "Alive";
                _patient.PatientAllergy    = rm.PatientAllergy;
                _patient.MedicalAidName    = rm.MedicalAidName;
                _patient.MedicalAidNo      = rm.MedicalAidNo;
                _patient.registeredDate    = DateTime.Now;
                _patient.PatientNo         = Patient_No;

                //Code to save the image to the Db
                if (rm.File != null && rm.File.ContentLength > 0)
                {
                    _patient.FileName    = System.IO.Path.GetFileName(rm.File.FileName);
                    _patient.FileType    = GlenwoodMed.Model.ViewModels.FileType.Avatar;
                    _patient.ContentType = rm.File.ContentType;

                    using (var reader = new System.IO.BinaryReader(rm.File.InputStream))
                    {
                        _patient.File = reader.ReadBytes(rm.File.ContentLength);
                    }
                }

                es.To      = rm.Email;
                es.Subject = "Registration Details";
                es.Body    = "Patient Number: " + Patient_No + "<br/>"
                             + "Username: "******"<br/>"
                             + "Password: "******"PatientId"] = _patient.PatientId;
                //}
            }
        }