public HttpResponseMessage ArchivePRCMR([FromBody] Claim_Update_Cmr updateCmr, int updateID, string token) { Session session = _ctx.Sessions.SingleOrDefault(i => i.SessionToken == token); Claim_Update_Cmr oldCMR = _ctx.Claim_Update_Cmrs.SingleOrDefault(i => i.UpdateID == updateID); Claim_Update_Cmr_Archive archive = new Claim_Update_Cmr_Archive() { UserID = oldCMR.UserID, UpdateID = oldCMR.UpdateID, AbsenceAuthorization = oldCMR.AbsenceAuthorization, ArchiveDate = DateTime.Now, ArchivedBy = Convert.ToInt32(session.UserID), ClaimHistoryInformation = oldCMR.ClaimHistoryInformation, ClaimStatusID = oldCMR.ClaimStatusID, DateOfAbsence = oldCMR.DateOfAbsence, DateOfReferal = oldCMR.DateOfReferal, DateOfReport = oldCMR.DateOfReport, EmployeeID = oldCMR.EmployeeID, EmployeeName = oldCMR.EmployeeName, EmployerContactID = oldCMR.EmployerContactID, Location = oldCMR.Location, NextSteps = oldCMR.NextSteps, OSIContactID = oldCMR.OSIContactID, ReturntoWorkRecommendations = oldCMR.ReturntoWorkRecommendations, TreatmentPlan = oldCMR.TreatmentPlan }; _ctx.Claim_Update_Cmr_Archives.InsertOnSubmit(archive); _ctx.SubmitChanges(); oldCMR.UserID = updateCmr.UserID; oldCMR.UpdateID = updateCmr.UpdateID; oldCMR.AbsenceAuthorization = updateCmr.AbsenceAuthorization; oldCMR.ClaimHistoryInformation = updateCmr.ClaimHistoryInformation; oldCMR.ClaimStatusID = updateCmr.ClaimStatusID; oldCMR.DateOfAbsence = updateCmr.DateOfAbsence; oldCMR.DateOfReferal = updateCmr.DateOfReferal; oldCMR.DateOfReport = updateCmr.DateOfReport; oldCMR.EmployeeID = updateCmr.EmployeeID; oldCMR.EmployeeName = updateCmr.EmployeeName; oldCMR.EmployerContactID = updateCmr.EmployerContactID; oldCMR.Location = updateCmr.Location; oldCMR.NextSteps = updateCmr.NextSteps; oldCMR.OSIContactID = updateCmr.OSIContactID; oldCMR.ReturntoWorkRecommendations = updateCmr.ReturntoWorkRecommendations; oldCMR.TreatmentPlan = updateCmr.TreatmentPlan; oldCMR.EmployeeContactID = updateCmr.EmployeeContactID; _ctx.SubmitChanges(); return(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent("Updated") }); }
public HttpResponseMessage SaveCmr([FromBody] Claim_Update_Cmr cmr) { context.Claim_Update_Cmrs.InsertOnSubmit(cmr); context.SubmitChanges(); return(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent("Inserted") }); }
public void SendCMRReportToClient(int UpdateID) { SmtpClient smtp = new SmtpClient(); MailMessage mm; Claim_Update_Cmr cmr = _ctx.Claim_Update_Cmrs.SingleOrDefault(i => i.UpdateID == UpdateID); if (cmr == null) { return; } Claim_Update claimUpdate = _ctx.Claim_Updates.SingleOrDefault(i => i.UpdateID == UpdateID); Claim_Contact EmployerContact = _ctx.Claim_Contacts.SingleOrDefault(i => i.ContactID == cmr.EmployerContactID); Claim_Emp_ContactTypeDetail EmployeeContact = _ctx.Claim_Emp_ContactTypeDetails.SingleOrDefault(i => i.EmpID == cmr.EmployeeContactID); List_ClaimStatus claimStatus = _ctx.List_ClaimStatus.SingleOrDefault(i => i.index == cmr.ClaimStatusID); List <string> emails = new List <string>(); User_Profile OSIContact = _ctx.User_Profiles.SingleOrDefault(i => i.UserID == cmr.OSIContactID); //emails.Add(EmployerContact.Con_Email); //emails.Add(EmployeeContact.ContactDetail); emails.Add("EmailHere"); //create email body string EmailTemplate = File.ReadAllText(HostingEnvironment.MapPath(@"~/EmailTemplates/CMREmailTemplate.html")); EmailTemplate = EmailTemplate.Replace(" {{ReportedComments}}", claimUpdate.ReportedComments); //create cmr pdf string cmrhtml = File.ReadAllText(HostingEnvironment.MapPath(@"~/EmailTemplates/CMRTemplate.html")); cmrhtml = cmrhtml.Replace("{{ClaimStatus}}", claimStatus.Status_EN); cmrhtml = cmrhtml.Replace("{{DateOfReport}}", cmr.DateOfReport.ToLongDateString()); cmrhtml = cmrhtml.Replace("{{EmployeeName}}", cmr.EmployeeName); cmrhtml = cmrhtml.Replace("{{EmployeeEmail}}", EmployeeContact.ContactDetail); cmrhtml = cmrhtml.Replace("{{EmployeeID}}", cmr.EmployeeID.ToString()); cmrhtml = cmrhtml.Replace("{{ReferalDate}}", cmr.DateOfReferal.ToLongDateString()); cmrhtml = cmrhtml.Replace("{{Location}}", cmr.Location); cmrhtml = cmrhtml.Replace("{{AbsenceDate}}", cmr.DateOfAbsence.ToLongDateString()); cmrhtml = cmrhtml.Replace("{{EmployerContact}}", EmployerContact.Con_Email); cmrhtml = cmrhtml.Replace("{{OSIContact}}", OSIContact.Email); cmrhtml = cmrhtml.Replace("{{HistoryInformation}}", cmr.ClaimHistoryInformation); cmrhtml = cmrhtml.Replace("{{AbsenceAuthorization}}", cmr.AbsenceAuthorization); cmrhtml = cmrhtml.Replace("{{TreatmentPlan}}", cmr.TreatmentPlan); cmrhtml = cmrhtml.Replace("{{Recommendations}}", cmr.ReturntoWorkRecommendations); cmrhtml = cmrhtml.Replace("{{NextSteps}}", cmr.NextSteps); string FilePath = HostingEnvironment.MapPath(@"~/TempFiles/ClaimUpdate" + claimUpdate.ClaimRefNu + "-" + DateTime.Now.ToString("dd-MM-yyyy") + ".pdf"); string Html = "<html><head><title></title><style>" + File.ReadAllText(HostingEnvironment.MapPath(@"~/Content/bootstrap.min.css")) + "</style></head><body>" + cmrhtml + "</body></html>"; var pdf = Pdf .From(Html) .OfSize(PaperSize.A4) .Content(); System.IO.File.WriteAllBytes(FilePath, pdf); foreach (string email in emails) { smtp.UseDefaultCredentials = false; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential("noreply", "44bananas55$"); smtp.Host = "connect.orgsoln.com"; //Change for smtp from OSI smtp.EnableSsl = false; smtp.Port = 25; mm = new MailMessage("*****@*****.**", email); mm.Subject = "Claim update for " + claimUpdate.ClaimRefNu; mm.IsBodyHtml = true; mm.Body = EmailTemplate; mm.Attachments.Add(new Attachment(FilePath)); smtp.Send(mm); smtp.Dispose(); mm.Attachments.Dispose(); File.Delete(FilePath); } }
public HttpResponseMessage ArchiveUpdate(string token, int updateID) { Claim_Update claimUpdate = context.Claim_Updates.Single(i => i.UpdateID == updateID); Session session = context.Sessions.FirstOrDefault(i => i.SessionToken == token); if (claimUpdate.DateTimeSubmitted_ < DateTime.UtcNow.AddHours(-2)) { return(new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Claim update exceeded 2 hours old, cannot be archived.") }); } if (claimUpdate.UserID != Convert.ToInt32(session.UserID)) { return(new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("You did not create this claim update. you cannot delete it") }); } Claim_Updates_Billing updatesBilling = context.Claim_Updates_Billings.Single(i => i.UpdateID == updateID); Claim_Update_Cmr oldCMR = context.Claim_Update_Cmrs.SingleOrDefault(i => i.UpdateID == updateID); List <Claim_Updates_Document> updatesDocuments = context.Claim_Updates_Documents.Where(i => i.UpdateID == updateID).ToList(); Claim_Peer_Review peerReview = context.Claim_Peer_Reviews.SingleOrDefault(i => i.Update_ID == updateID); Claim_Updates_Billing_PR_Archive archive = new Claim_Updates_Billing_PR_Archive() { UserID = claimUpdate.UserID, ClaimRefNu = claimUpdate.ClaimRefNu, ActionType = claimUpdate.ActionType, Archived_By = Convert.ToInt32(session.UserID), BillID = updatesBilling.BillID, Billable = claimUpdate.Billable, Comments = updatesBilling.Comments, Completed = updatesBilling.Completed, CompletionDate = updatesBilling.CompletionDate, Courier = updatesBilling.Courier, Date_Archived = DateTime.Now, DirectContact = updatesBilling.DirectContact, Duration = updatesBilling.Duration, EmployeeComments = claimUpdate.EmployeeComments, InternalComments = claimUpdate.InternalComments, IsArchived = claimUpdate.IsArchived, IsInReview = false, Method = updatesBilling.Method, Postage = updatesBilling.Postage, Reason = updatesBilling.Reason, ReportedComments = claimUpdate.ReportedComments, UpdateBy = Convert.ToInt32(session.UserID), UpdateId = claimUpdate.UpdateID, UpdatesDate = claimUpdate.UpdatesDate, SeniorConsulting = updatesBilling.SeniorConsulting }; if (oldCMR != null) { Claim_Update_Cmr_Archive cmrarchive = new Claim_Update_Cmr_Archive() { UserID = oldCMR.UserID, UpdateID = oldCMR.UpdateID, AbsenceAuthorization = oldCMR.AbsenceAuthorization, ArchiveDate = DateTime.Now, ArchivedBy = Convert.ToInt32(session.UserID), ClaimHistoryInformation = oldCMR.ClaimHistoryInformation, ClaimStatusID = oldCMR.ClaimStatusID, DateOfAbsence = oldCMR.DateOfAbsence, DateOfReferal = oldCMR.DateOfReferal, DateOfReport = oldCMR.DateOfReport, EmployeeID = oldCMR.EmployeeID, EmployeeName = oldCMR.EmployeeName, EmployerContactID = oldCMR.EmployerContactID, Location = oldCMR.Location, NextSteps = oldCMR.NextSteps, OSIContactID = oldCMR.OSIContactID, ReturntoWorkRecommendations = oldCMR.ReturntoWorkRecommendations, TreatmentPlan = oldCMR.TreatmentPlan }; context.Claim_Update_Cmr_Archives.InsertOnSubmit(cmrarchive); } foreach (Claim_Updates_Document doc in updatesDocuments) { Claim_Updates_Documents_Archive docarchive = new Claim_Updates_Documents_Archive() { UserID = doc.UserID, UpdateID = doc.UpdateID, ArchivedBy = Convert.ToInt32(session.UserID), ClaimReference = doc.ClaimReference, DateArchived = DateTime.Now, DocumentID = doc.DocumentID, FileExt = doc.FileExt, FileName = doc.FileName, Timestamp = doc.Timestamp, VersionNumber = doc.VersionNumber }; context.Claim_Updates_Documents_Archives.InsertOnSubmit(docarchive); } if (peerReview != null) { context.Claim_Peer_Reviews.DeleteOnSubmit(peerReview); } context.Claim_Updates_Billing_PR_Archives.InsertOnSubmit(archive); context.SubmitChanges(); context.Claim_Updates.DeleteOnSubmit(claimUpdate); context.Claim_Updates_Billings.DeleteOnSubmit(updatesBilling); if (oldCMR != null) { context.Claim_Update_Cmrs.DeleteOnSubmit(oldCMR); } foreach (Claim_Updates_Document doc in updatesDocuments) { context.Claim_Updates_Documents.DeleteOnSubmit(doc); } context.SubmitChanges(); return(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent("Claim update and child records successfuly archived") }); }