public ActionResult DoctorManage(DocQuery q) { emailableModel <Doctor> aDoc = new emailableModel <Doctor>(); aDoc.model = smokeFreeDB.Doctor.Find(q.id); return(View(aDoc)); }
public ActionResult ArticleManage(ArticleQuery q) { emailableModel <Article> aArticle = new emailableModel <Article>(); aArticle.model = smokeFreeDB.Article.Find(q.id); return(View(aArticle)); }
public ActionResult RejectPost(emailableModel <Article> aModel) { EmailMessage theMail = aModel.emailModel; Article theArticle = aModel.model; var article = smokeFreeDB.Article.Find(theArticle.articleID); var doc = smokeFreeDB.GeneralUser.Find(article.userName); const string systemEmail = "*****@*****.**"; const string systemEmailPw = "Omaewamou"; // dont hack me , thx article.articleStatus = "rejected"; smokeFreeDB.SaveChanges(); try { MailMessage mail = new MailMessage(); //string testEmail = "*****@*****.**"; mail.To.Add(doc.email); mail.From = new MailAddress(systemEmail); if (String.IsNullOrEmpty(theMail.Subject)) { mail.Subject = "Article Rejected - Thank you for your interest"; } else { mail.Subject = theMail.Subject; } if (String.IsNullOrEmpty(theMail.Body)) { mail.Body = "Hi Sir/Mdm,\n Sorry, we have deemed it unfit to be posted. Please submit another request\n Thank you"; } else { mail.Body = theMail.Body; } mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential(systemEmail, systemEmailPw); // Enter senders User name and password smtp.EnableSsl = true; smtp.Send(mail); } catch (Exception e) { //hmmm.... } ViewBag.activeTabContent = "Pending Article"; return(View("Manage", populateView())); }
public ActionResult RejectDoc(emailableModel <Doctor> aModel) { EmailMessage theMail = aModel.emailModel; Doctor theDoc = aModel.model; var aDocc = smokeFreeDB.Doctor.Find(theDoc.userName); var aDoc = smokeFreeDB.GeneralUser.Find(aDocc.userName); const string systemEmail = "*****@*****.**"; const string systemEmailPw = "Omaewamou"; // dont hack me , thx if ((aDocc != null && aDoc == null) || (aDocc == null && aDoc != null)) { //anomally in db //no email is sent as this is a data inconsistency if (aDocc != null) { smokeFreeDB.Doctor.Remove(aDocc); } if (aDoc != null) { smokeFreeDB.GeneralUser.Remove(aDoc); } smokeFreeDB.SaveChanges(); ViewBag.activeTabContent = "Pending Doctor"; return(View("Manage", populateView())); } try { smokeFreeDB.Doctor.Remove(aDocc); smokeFreeDB.GeneralUser.Remove(aDoc); smokeFreeDB.SaveChanges(); MailMessage mail = new MailMessage(); mail.To.Add(aDoc.email); mail.From = new MailAddress(systemEmail); if (String.IsNullOrEmpty(theMail.Subject)) { mail.Subject = "Registration rejected - Thank you for your interest"; } else { mail.Subject = theMail.Subject; } if (String.IsNullOrEmpty(theMail.Body)) { mail.Body = "Hi Sir/Mdm,\n Sorry, we have deem you unfit to be accepted. Please submit another request\n Thank you"; } else { mail.Body = theMail.Body; } mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential(systemEmail, systemEmailPw); // Enter senders User name and password smtp.EnableSsl = true; smtp.Send(mail); } catch (Exception e) { //hmmm.... } ViewBag.activeTabContent = "Pending Doctor"; return(View("Manage", populateView())); }