public string PlanningFormMailGenerator(ProgrammePlanning programmePlanningForm) { StringBuilder sb = new StringBuilder(); sb.Append("<br/><br/> <hr size='5' style='background-color:#E00'/><br/>" + "<table cellpadding='10' style='border-spacing:15px 0rem; font-family:'Times New Roman', Times, serif; font-size:16px;'>" + "<tr><td style='width:350px;word-wrap:break-word;'>Planning Number :</td><td>"); sb.Append(programmePlanningForm.PlanningNumber); sb.Append("</td></tr>"); sb.Append("<tr><td style = 'width:350px; word-wrap: break-word;'>Planning Month and Year :</td><td>"); sb.Append(programmePlanningForm.PlanningMonthAndYear); sb.Append("</td></tr>"); sb.Append("<tr><td style = 'width:350px; word-wrap: break-word;'>Planning Category :</td><td>"); sb.Append(programmePlanningForm.PlanningCategory); sb.Append("</td></tr>"); sb.Append("<tr><td style = 'width:350px; word-wrap: break-word;'>Village Code :</td><td>"); sb.Append(programmePlanningForm.VillageCode); sb.Append("</td></tr>"); sb.Append("<tr><td style = 'width:350px; word-wrap: break-word;'>Planned Pre-SVP date :</td><td>"); sb.Append(programmePlanningForm.PlannedPreSvpDate.ToShortDateString()); sb.Append("</td></tr>"); sb.Append("<tr><td style = 'width:350px; word-wrap: break-word;'>Planned SVP date :</td><td>"); sb.Append(programmePlanningForm.PlannedSvpDate.ToShortDateString()); sb.Append("</td></tr>"); sb.Append("</table><br/><br/><hr size='5' style='background-color:#E00'/><br/>"); return(sb.ToString()); }
public string SaveProgrammePlanningForm(ProgrammePlanning programmePlanningForm) { int newFormNumber = 1; IQueryable <SerialNumbertrackerRA> queryableSerialNumberTrackerRAData = this.unitOfWork.DbContext.SerialNumbertrackerRA .Where(x => x.UserCode == programmePlanningForm.CreatedBy && x.FormType == "PL"); if (queryableSerialNumberTrackerRAData.Any()) { newFormNumber = queryableSerialNumberTrackerRAData.Max(y => y.SerialValue) + 1; } string padding = "000"; string serialNumberComponent = padding.Remove(padding.Length - newFormNumber.ToString().Length) + (newFormNumber).ToString(); programmePlanningForm.PlanningNumber = "PL-" + programmePlanningForm.CreatedBy + "-" + serialNumberComponent; /*Form entry */ ProgrammePlanning planningObj = this.unitOfWork.DbContext.ProgrammePlanning.Add(programmePlanningForm); /*Serial Number updation*/ SerialNumbertrackerRA serialNumbertrackerRAObj = new SerialNumbertrackerRA { FormType = "PL", UserCode = programmePlanningForm.CreatedBy, SerialValue = newFormNumber, GeneratedDate = DateTime.UtcNow.AddHours(5.5) }; serialNumbertrackerRAObj = this.unitOfWork.DbContext.SerialNumbertrackerRA.Add(serialNumbertrackerRAObj); this.unitOfWork.DbContext.SaveChanges(); return(planningObj.PlanningNumber); }
public string SaveProgrammePlanningForm(ProgrammePlanning programmePlanningForm) { var planningNumber = this.svpDataAccess.SaveProgrammePlanningForm(programmePlanningForm); this.SendPlanningFormResponseMail(programmePlanningForm); return(planningNumber); }
public IActionResult SaveProgrammePlanningForm([FromBody] ProgrammePlanning programmePlanningForm) { programmePlanningForm.CreatedDateTime = DateTime.UtcNow.AddHours(5.5); var updatedForm = this._svpBusinessAccess.SaveProgrammePlanningForm(programmePlanningForm); return(Ok(updatedForm)); }
public void SendPlanningFormResponseMail(ProgrammePlanning programmePlanningForm) { var generatedPdfTemplateString = pdfTemplate.PlanningFormMailGenerator(programmePlanningForm); var redAlertUser = this.svpDataAccess.GetUserDetails(programmePlanningForm.CreatedBy); string subject = $"Team ORA - Confirmation: Planning Form {programmePlanningForm.PlanningNumber} Received "; string body = $"<img src='https://drive.google.com/uc?id=1Ri4dvgKuyRlK3MYxgqueIDO3OFyBKe5a'/> <br/>Dear {redAlertUser.Organization}, " + $"<br/><br/><br/>We received the planning details for the month of {programmePlanningForm.PlanningMonthAndYear}. " + $"Please find the attached PDF for the submitted details.<br/><br/>Wish you all the best for the upcoming programs." + $"<br/><br/>Team ORA"; string pdfName = $"{programmePlanningForm.PlanningNumber}.pdf"; ipPdfMailer.SendMailToUser(generatedPdfTemplateString, redAlertUser.UserName, subject, body, pdfName); }