public IActionResult Create(SendingModel sModel, int studyID) { ViewStudyModelHelper viewStudyModelHelper = new ViewStudyModelHelper(); sModel.Study = viewStudyModelHelper.createViewStudyModel(studyID); if (ModelState.IsValid) { try { // Convert to create the right format EmailHelper emailHelper = new EmailHelper(); emailHelper.SendMessages(sModel, studyID); return(RedirectToAction("Researcher", "Homepage")); } catch (Exception e) { //Should store error in a internal log. return(View("Index")); } } IManageParticipantHandler mph1 = new ManageParticipantHandler(new bachelordbContext()); List <Participant> participants1 = mph1.GetAllEligibalParticipants(sModel.Study.inclusioncriteria, studyID); sModel.ParticipantCount = participants1.Count; return(View("index", sModel)); }
public ActionResult RemoveParticipant(ManageParticipantModel mpModel) { IManageParticipantHandler mph = new ManageParticipantHandler(new bachelordbContext()); if (ModelState.IsValid) { try { DbStatus manageParticipantStatus = mph.RemoveParticipantFromStudyDB(mpModel.participantID, mpModel.studyID); if (manageParticipantStatus.success) { return(RedirectToAction("ManageParticipants", "ManageParticipants", new { studyID = mpModel.studyID, studyName = mpModel.nameOfStudy })); } else { ModelState.AddModelError("ParticipantID", manageParticipantStatus.errormessage); } } catch (Exception) { throw; } } mpModel.participants = mph.GetParticipantsInStudyDB(mpModel.studyID); return(View("ManageParticipants", mpModel)); }
public ManageParticipantModel CreateManageParticipantModel(int studyID, string studyName) { ManageParticipantHandler mph = new ManageParticipantHandler(new bachelordbContext()); ManageParticipantModel manageParticipantModel = new ManageParticipantModel(); manageParticipantModel.participants = mph.GetParticipantsInStudyDB(studyID); manageParticipantModel.nameOfStudy = studyName; manageParticipantModel.studyID = studyID; return(manageParticipantModel); }
public IActionResult Index(int studyID) { ViewStudyModelHelper viewStudyModelHelper = new ViewStudyModelHelper(); SendingModel sendToParticipantModel = new SendingModel(); sendToParticipantModel.Study = viewStudyModelHelper.createViewStudyModel(studyID); EmailHelper emailHelper = new EmailHelper(); emailHelper.PrefillTextArea(sendToParticipantModel); IManageParticipantHandler mph = new ManageParticipantHandler(new bachelordbContext()); List <Participant> participants = mph.GetAllEligibalParticipants(sendToParticipantModel.Study.inclusioncriteria, studyID); sendToParticipantModel.ParticipantCount = participants.Count; return(View(sendToParticipantModel)); }
public ActionResult GetEmail(ManageParticipantModel mpModel) { IManageParticipantHandler mph = new ManageParticipantHandler(new bachelordbContext()); try { DbStatus manageParticipantStatus = mph.GetParticipantEmailDB(mpModel.participantID); if (manageParticipantStatus.success) { mpModel.participantEmail = manageParticipantStatus.participantEmail; } else { ModelState.AddModelError("ParticipantID", manageParticipantStatus.errormessage); mpModel.participantEmail = ""; } } catch (Exception) { throw; } mpModel.participants = mph.GetParticipantsInStudyDB(mpModel.studyID); return(View("ManageParticipants", mpModel)); }
public void SendToParticipants(SendingModel sModel, int studyId) { //Getting participants from DB IManageParticipantHandler mph = new ManageParticipantHandler(new bachelordbContext()); List <Participant> participants = mph.GetAllEligibalParticipants(sModel.Study.inclusioncriteria, studyId); foreach (var participant in participants) { var message = new MimeMessage(); message.From.Add(new MailboxAddress("Tandlægehøjskolen", "donotreplyTandlægeHø[email protected]")); message.To.Add(new MailboxAddress("Participant for Tandlægehøjskolen", participant.Email)); var builder = new BodyBuilder(); builder.HtmlBody = sModel.Mail.MailBody + System.Environment.NewLine + "" + System.Environment.NewLine + "" + System.Environment.NewLine; SendingWithSmtpClient(builder, message, sModel.Mail.Subject); } }