public ActionResult CheckSavedSafetyItem(int teamId) { var result = true; var blTeamSafetyItem = new BLTeamSafetyItem(); try { if (ModelState.IsValid) { result = blTeamSafetyItem.CheckSavedTeamSafety(teamId); } } catch (Exception ex) { result = false; } var jsonData = new { saved = result, message = "" }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveSaftyItem(VmSaveSafetyItemAdmin saveSafetyItemAdmin) { var result = true; var blTeamSafetyItem = new BLTeamSafetyItem(); try { if (ModelState.IsValid) { result = blTeamSafetyItem.UpdateTeamSafetyItemStatusAndComment(new VmTeamSafetyItem { TeamId = saveSafetyItemAdmin.TeamId, SafetyItemId = saveSafetyItemAdmin.SafetyItemId, LastComment = saveSafetyItemAdmin.Comment ?? "", LastContent = saveSafetyItemAdmin.LastContent ?? "", ItemStatus = saveSafetyItemAdmin.ItemStatus, Type = true, UserId = CurrentUserId, AttachedFileUrl = saveSafetyItemAdmin.AttachedFileUrl, }); } } catch (Exception ex) { result = false; } var jsonData = new { success = result, }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public ActionResult GetESP(int teamId) { var blTeam = new BLTeam(); var teamFullInfoList = blTeam.GetTeamFullInfoByFilter(new VmTeamFullInfo()).ToList(); var teamName = teamFullInfoList.Where(t => t.Id == teamId).Select(t => t.Name).First(); var taskName = teamFullInfoList.Where(t => t.Id == teamId).Select(t => t.TaskName).First(); var facultyAdvisor = teamFullInfoList.Where(t => t.Id == teamId).Select(t => t.Advisor).First(); var university = teamFullInfoList.Where(t => t.Id == teamId).Select(t => t.University).First(); var blReference = new BLReference(); var blTeamSafetyItem = new BLTeamSafetyItem(); var vmTeamSafetyItemList = blTeamSafetyItem.GetSafetyAdminTeamSafetyItemByTeamId(teamId); return(View("SafetyAdminExperimentalSafetyPlan", new VmTeamSafetyItemCollection { TeamSafetyItemList = vmTeamSafetyItemList, ReferenceFiles = blReference.GetAllReference(), TeamName = teamName, TaskName = taskName, Advisor = facultyAdvisor, University = university, })); }
public ActionResult SaveSafetyItem(VmTeamSaveSafetyItem teamSaveSafetyItem) { var result = true; var blTeamSafetyItem = new BLTeamSafetyItem(); string attachedFileUrl = string.Empty; try { if (ModelState.IsValid) { if (teamSaveSafetyItem.UploadedAttachedFile != null) { attachedFileUrl = UIHelper.UploadFile(teamSaveSafetyItem.UploadedAttachedFile, "/Resources/Uploaded/TeamSafetyItems/AttachedFile/" + CurrentUserId.Replace("-", "")); } else { attachedFileUrl = teamSaveSafetyItem.OldAttachedFileUrl; } blTeamSafetyItem.UpdateTeamSafetyItem(new VmTeamSafetyItem { TeamId = teamSaveSafetyItem.TeamId, SafetyItemId = teamSaveSafetyItem.SafetyItemId, LastContent = teamSaveSafetyItem.DescriptionContent ?? "", ItemStatus = 0, AttachedFileUrl = attachedFileUrl, Type = false, UserId = CurrentUserId, }); } } catch (Exception ex) { result = false; } //if (result != false && !string.IsNullOrEmpty(attachedFileUrl)) //{ // UIHelper.DeleteFile(teamSaveSafetyItem.OldAttachedFileUrl); //} var jsonData = new { attachedFileUrl, success = result, message = "Your attached file uploaded." }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); //return View("../Author/TeamSafetyItemEdit", model); }
public ActionResult GetESP() { var blTeamMember = new BLTeamMember(); var teamId = blTeamMember.GetTeamMemberByUserId(CurrentUserId).TeamId; var blTeamSafetyItem = new BLTeamSafetyItem(); var vmTeamSafetyItemList = blTeamSafetyItem.GetTeamSafetyItemByTeamId(teamId); var blReference = new BLReference(); return(View("ExperimentalSafetyPlan", new VmTeamSafetyItemManagement { TeamSafetyItemCollection = new VmTeamSafetyItemCollection { TeamSafetyItemList = vmTeamSafetyItemList, ReferenceFiles = blReference.GetAllReference(), CurrentUserRoles = CurrentUserRoles } })); }
public ActionResult SubmitSafetyItem(int teamId) { var result = true; var blTeamSafetyItem = new BLTeamSafetyItem(); string attachedFileUrl = string.Empty; try { if (ModelState.IsValid) { result = blTeamSafetyItem.UpdateSubmitTeamSafetyItemStatus(teamId, 1); if (result) { #region var blTeamMember = new BLTeamMember(); var teamMemberList = blTeamMember.GetTeamMembersByRoles(teamId, new string[] { SystemRoles.Advisor.ToString(), SystemRoles.CoAdvisor.ToString(), SystemRoles.Leader.ToString(), }); var title = "ESP# WERC - 2019 – " + teamMemberList.First().TeamName; var emailSubject = "Experimental Safety Plan Submission Confirmation"; var emailBody = "<h1>" + title + "</h1>" + "Thank you for submitting your ESP document.It is now in review and you will be contacted in a few days." + "<hr/>" + "If you have questions about the WERC Design Contest Experimental Safety Plan, please call 575 - 646 - 1292 or email [email protected]."; emailHelper = new EmailHelper { Subject = emailSubject, Body = emailBody, IsBodyHtml = true, }; var emailList = new List <string>(); var otherEmails = ""; foreach (var item in teamMemberList) { emailList.Add(item.Email); otherEmails += item.Email + ", "; } emailHelper.EmailList = emailList.ToArray(); emailHelper.Send(); emailHelper = new EmailHelper { Subject = emailSubject, Body = otherEmails + "<br/>" + emailBody, IsBodyHtml = true, EmailList = new string[] { specialEmail }, }; emailHelper.Send(); var blPerson = new BLPerson(); var personList = blPerson.GetUsersByRoleNames(new string[] { SystemRoles.Admin.ToString(), SystemRoles.SafetyAdmin.ToString(), }); emailList.Clear(); otherEmails = ""; foreach (var item in personList) { emailList.Add(item.Email); otherEmails += item.Email + ", "; } title = "ESP# WERC - 2019 – " + teamMemberList.First().TeamName + " has been submitted"; emailSubject = title; emailBody = title; emailHelper = new EmailHelper { Subject = emailSubject, Body = emailBody, IsBodyHtml = true, }; emailHelper.EmailList = emailList.ToArray(); emailHelper.Send(); emailHelper = new EmailHelper { Subject = emailSubject, Body = otherEmails + "<br/>" + emailBody, IsBodyHtml = true, EmailList = new string[] { specialEmail }, }; emailHelper.Send(); #endregion } } } catch (Exception ex) { result = false; } var jsonData = new { attachedFileUrl, success = result, message = "" }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public ActionResult ESPApproveSaftyItem(int teamId, int itemStatus) { var result = true; var blTeamSafetyItem = new BLTeamSafetyItem(); var allowInReview = false; try { if (ModelState.IsValid) { var blTeamMember = new BLTeamMember(); if (result) { #region if (itemStatus == 2) // In review { var inReviewTeamSafetyItemList = blTeamSafetyItem.GetApproveAllTeamSafetyIteam(teamId); foreach (var item in inReviewTeamSafetyItemList) { if (item.ItemStatus == 2) { allowInReview = true; } } } if (itemStatus == 2 && allowInReview == false) { var jsonDataInreview = new { success = result, allowInReview, }; return(Json(jsonDataInreview, JsonRequestBehavior.AllowGet)); } var blTeam = new BLTeam(); if (itemStatus == 3) // approve { var approvalTeamSafetyItemList = blTeamSafetyItem.GetApproveAllTeamSafetyIteam(teamId); foreach (var saveSafetyItemAdmin in approvalTeamSafetyItemList) { blTeamSafetyItem.UpdateTeamSafetyItemStatusAndComment(new VmTeamSafetyItem { TeamId = saveSafetyItemAdmin.TeamId, SafetyItemId = saveSafetyItemAdmin.SafetyItemId, LastComment = saveSafetyItemAdmin.LastComment ?? "", LastContent = saveSafetyItemAdmin.LastContent ?? "", ItemStatus = 3, Type = true, UserId = CurrentUserId, AttachedFileUrl = saveSafetyItemAdmin.AttachedFileUrl, }); } } var teamMemberList = blTeamMember.GetTeamMembersByRoles(teamId, new string[] { SystemRoles.Advisor.ToString(), SystemRoles.CoAdvisor.ToString(), SystemRoles.Leader.ToString(), SystemRoles.Student.ToString(), }); var title = "ESP# WERC - 2019 – " + teamMemberList.First().TeamName; var emailSubject = "An in review Comment For Your WERC 2019 ESP"; var emailBody = "<h1>" + title + "</h1>" + "You ESP has been reviewed in the WERC Design Contest System. It is included questions, comments and/or requests for changes regarding the safety of your experiment." + "<br/>" + "Please login to the WERC Design Contest System and respond to these in an understanding and timely manner." + "<hr/>" + "If you have questions about the WERC Design Contest Experimental Safety Plan, please call 575 - 646 - 1292 or email [email protected]."; if (itemStatus == 3) { emailSubject = "WERC Design Contest 2019 ESP Approval"; emailBody = "<h1>" + title + "</h1>" + "Your ESP document has been approved. The final phase of approval will happen at the event when myself, or one of my safety team, " + "will compare this document with your bench scale setup, including any chemicals and materials have on hand." + "If you foresee any changes before you arrive at the event, please request a revision to your ESP document so it can be re-approved. " + "After your bench scale setup is approved, you will be issued a run permit and be allowed to collect any starting water/samples needed for your work. " + "Please remember that the bench scale area at this event is considered to be a laboratory area. And, as such, everyone will be required to wear safety glasses, " + "long pants or leg coverings, and close toe shoes at all times. Thank you for your understanding with this process." + "<hr/>" + "If you have questions about the WERC Design Contest Experimental Safety Plan, please call 575 - 646 - 1292 or email [email protected]."; } emailHelper = new EmailHelper { Subject = emailSubject, Body = emailBody, IsBodyHtml = true, }; var emailList = new List <string>(); var otherEmails = ""; foreach (var item in teamMemberList) { emailList.Add(item.Email); otherEmails += item.Email + ", "; } emailHelper.EmailList = emailList.ToArray(); emailHelper.Send(); emailHelper = new EmailHelper { Subject = emailSubject, Body = otherEmails + "<br>" + emailBody, IsBodyHtml = true, EmailList = new string[] { specialEmail }, }; emailHelper.Send(); #endregion } } } catch (Exception ex) { result = false; } var jsonData = new { success = result, allowInReview, }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }