//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 ActionResult Delete(int id, Email_serviceViewModel ee) { try { db.PostDeleteMethod(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, Email_serviceViewModel emailcollection) { try { // TODO: Add update logic here // db.PostEditMethod(emailcollection); return(RedirectToAction("Index")); } catch { return(View()); } }
//[Authorize] public ActionResult Create(Email_serviceViewModel email_services_)//, HttpPostedFileBase fileUploader) { try { email_services_.StaffName = User.Identity.Name; // TODO: Add insert logic herezzZZZ db.createemail(email_services_);//, fileUploader); TempData["msg"] = "Email was sent successfully"; return(RedirectToAction("Index")); } catch { return(View()); } }
//public void updateemails(Email_services emails) //{ //} #endregion public Email_serviceViewModel EmailDetails(int?id) { Email_serviceViewModel em = new Email_serviceViewModel(); using (var emailrepo = new EmailRepository()) { if (id.HasValue && id != 0) { Email_services ema = emailrepo.GetById(id.Value); em.To = ema.To; em.Cc = ema.Cc; em.Bcc = ema.Bcc; em.Subject = ema.Subject; em.Body = ema.Body; em.StaffName = ema.StaffName; } return(em); } }
public Email_serviceViewModel GETdeleteMethod(int id) { Email_serviceViewModel ma = new Email_serviceViewModel(); using (var mailrepo = new EmailRepository()) { if (id != 0) { Email_services _email = mailrepo.GetById(id); ma.emailID = _email.emailID; ma.Cc = _email.Cc; ma.Body = _email.Body; ma.To = _email.To; ma.Bcc = _email.Bcc; ma.Subject = _email.Subject; ma.StaffName = _email.StaffName; } return(ma); } }
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; //} } }
public void createemail(Email_serviceViewModel emails)//, HttpPostedFileBase fileUploader) { PatientBusiness dbl = new PatientBusiness(); using (var emailrepo = new EmailRepository()) { List <MailAddress> l = new List <MailAddress>(); MailMessage mail = new MailMessage(); if (emails.To == null) { foreach (Patient f in dbl.GetPatients())//for each friend { //get the email address and convert to MailAddress l.Add(new MailAddress(f.Email));//add to the list of receivers } to = l; foreach (MailAddress ma in to) //get each MailAddress in the list { mail.To.Add(ma); //use to set the to list Email_services _email = new Email_services { emailID = emails.emailID, To = ma.ToString(), Cc = emails.Cc, Bcc = emails.Bcc, Subject = emails.Subject, StaffName = emails.StaffName, Body = emails.Body }; emailrepo.Create(_email); } //mail.To.Add(l); } else { string[] ToMuliId = emails.To.Split(','); foreach (string ToEMailId in ToMuliId) { mail.To.Add(new MailAddress(ToEMailId)); //adding multiple TO Email Id } } /*mail.To.Add(emails.To);*/ mail.From = new MailAddress("*****@*****.**"); if (!string.IsNullOrEmpty(emails.Cc)) { string[] CCId = emails.Cc.Split(','); foreach (string CCEmail in CCId) { mail.CC.Add(new MailAddress(CCEmail)); //Adding Multiple CC email Id } } if (!string.IsNullOrEmpty(emails.Bcc)) { string[] bccid = emails.Bcc.Split(','); foreach (string bccEmailId in bccid) { mail.Bcc.Add(new MailAddress(bccEmailId)); //Adding Multiple BCC email Id } } #region /* if (emails.Cc == null) * { * mail.CC.Add("*****@*****.**"); * } * else * { * string[] CCId = emails.Cc.Split(','); * foreach (string CCEmail in CCId) * { * * mail.CC.Add(new MailAddress(CCEmail)); //Adding Multiple CC email Id * } * }*/ /* if (emails.Bcc == null) * { * mail.Bcc.Add("*****@*****.**"); * } * else * { * string[] bccid = emails.Bcc.Split(','); * foreach (string bccEmailId in bccid) * { * * mail.Bcc.Add(new MailAddress(bccEmailId)); //Adding Multiple BCC email Id * } * * } */ #endregion #region //else //{ // mail.CC.Add(emails.Cc); //} //if (emails.Bcc == null) //{ // mail.Bcc.Add("*****@*****.**"); //} //else //{ // mail.Bcc.Add(emails.Bcc); //} #endregion if (!string.IsNullOrEmpty(emails.Subject)) { mail.Subject = emails.Subject; } /* if (emails.Subject == null) * { * mail.Subject = "No subject"; * } * else * { * mail.Subject = emails.Subject; * } */ string Body = emails.Body; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); #region configurations is in the web.config /* smtp.Host = "localhost";//"smtp.live.com"; * //smtp.Host = "smtp.live.com"; * * smtp.Port = 25; //587; * // smtp.Port=587; */ #endregion smtp.Host = "smtp.sendgrid.net"; smtp.Port = 2525; smtp.UseDefaultCredentials = false; smtp.EnableSsl = true; smtp.Credentials = new System.Net.NetworkCredential("bigiayomide", "123adenike");// enter seders user name and password smtp.Send(mail); if (emails.emailID == 0) { Email_services _email = new Email_services { emailID = emails.emailID, To = emails.To, Cc = emails.Cc, Bcc = emails.Bcc, Subject = emails.Subject, StaffName = emails.StaffName, Body = emails.Body }; emailrepo.Create(_email); } } }