public ActionResult Index([Bind(Include = "AppointmentDate,AppointmentType,Name,Gender,DateOfBirth,PlaceOfBirth,Nationality,NRIC_No,PassportNumber,PassportIssuedDate,ConsulateLocation,StayType,StayPermitNumber,EmployerName,Occupation,ContactAddr1,ContactAddr2,ContactPhone,ContactEmail,HomeAddr1,HomeAddr2,HomePhone,Note")] ConsularApptVM consularApptVM) { if (!ModelState.IsValid) { this.LogModelStateError(); } ViewBag.Title = "Embassy Consular Appointment Form (Admin)"; consularApptVM.Note = "[ADMIN]" + consularApptVM.Note; EmbassyAppDb.AddConsularAppt(consularApptVM, EmWebAppConfig.QueueNumberInitial); DateTime? confirmedApptDate = null; int? confirmedQueNumber = 0; ConsularApptVM consularApptVM2 = EmbassyAppDb.ConfirmConsularAppt(consularApptVM.Id, consularApptVM.ActivationCode, ref confirmedApptDate, ref confirmedQueNumber); consularApptVM.QueueNumber = confirmedQueNumber.GetValueOrDefault(); ViewBag.PartialHtml = "_MsgApptConfirmedByAdmin"; AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(consularApptVM.AppointmentType); ViewBag.AppointmentType = appointmentType.Description; return(View(consularApptVM)); }
public ActionResult Index([Bind(Include = "RequesterType,TotalNumberOfApplications,AppointmentDate,AppointmentType,Name,Gender,DateOfBirth,PlaceOfBirth,Nationality,NRIC_No,PassportNumber,PassportIssuedDate,ContactAddr1,ContactAddr2,ContactPhone,ContactEmail,Note")] ConsularApptVM consularApptVM) { if (!ModelState.IsValid) { this.LogModelStateError(); } ViewBag.Title = _formTile + " (Admin)"; consularApptVM.Note = "[ADMIN]" + consularApptVM.Note; DpWebAppDb.AddConsularAppt(consularApptVM, DpWebAppConfig.QueueNumberInitial); DateTime? confirmedApptDate = null; int? confirmedQueNumber = 0; ConsularApptVM consularApptVM2 = DpWebAppDb.ConfirmConsularAppt(consularApptVM.ID, consularApptVM.ActivationCode, ref confirmedApptDate, ref confirmedQueNumber); consularApptVM.QueueNumber = confirmedQueNumber.GetValueOrDefault(); ViewBag.PartialHtml = "_MsgApptConfirmedByAdmin"; AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(consularApptVM.AppointmentType); ViewBag.AppointmentType = appointmentType.Description; return(View(consularApptVM)); }
// GET: ConsularAppt/Details/5 public ActionResult Details(int id) { ConsularApptVM model = EmbassyAppDb.GetConsularApptById(id); AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(model.AppointmentType); ViewBag.AppointmentType = appointmentType.Description; return(View(model)); }
// GET: Admin/PrintApptLtr/5 public ActionResult PrintApptLtr(int id) { ConsularApptVM model = EmbassyAppDb.GetConsularApptById(id); AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(model.AppointmentType); string pdfTemplateFile = ConfirmationLetterPdf.GetPdfTemplateFileName(appointmentType, model.StayType); MemoryStream pdfStream = ConfirmationLetterPdf.GetAppointmentLetterStream(pdfTemplateFile, model); //string confirmationLetter = this.GetConfirmationLetter(id); //MemoryStream pdfStream = new MemoryStream(); //Pdf.WriteHtmlToPdfStream(confirmationLetter, pdfStream); return(new FileStreamResult(pdfStream, "application/pdf")); }
// GET: Admin/PrintApptLtr/5 public ActionResult PrintApptLtr(int id) { ConsularApptVM model = DpWebAppDb.GetConsularApptById(id); AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(model.AppointmentType); string pdfTemplateFile = DpWebAppConfig.CnslrLtrPdfTmplPath + appointmentType.ConsularLtrPdfTmplFilename; MemoryStream pdfStream = ConfirmationLetterPdf.GetAppointmentLetterStream(pdfTemplateFile, model); //string confirmationLetter = this.GetConfirmationLetter(id); //MemoryStream pdfStream = new MemoryStream(); //Pdf.WriteHtmlToPdfStream(confirmationLetter, pdfStream); return(new FileStreamResult(pdfStream, "application/pdf")); }
private static void SetViewBagForConfirmationLetter(this Controller cntlr, ConsularApptVM consularApptVM) { if (cntlr.ViewBag.Logo == null) { string basePath = AppDomain.CurrentDomain.BaseDirectory; cntlr.ViewBag.Logo = Graphics.GetImgSrcForPdf(basePath + DpWebAppConfig.Emblem_Logo); } // Get Service Type look up if (cntlr.ViewBag.AppointmentType == null) { AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(consularApptVM.AppointmentType); cntlr.ViewBag.AppointmentType = appointmentType.Description; } // Get QR code if (cntlr.ViewBag.QR == null) { cntlr.ViewBag.QR = Graphics.GenerateRelayQrCode(ConfirmationLetterPdf.GetQrCodeString(consularApptVM)); } }
public static string GetConfirmedEmailBody(this Controller cntlr, ConsularApptVM consularApptVM) { string actionName = cntlr.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = cntlr.ControllerContext.RouteData.Values["controller"].ToString(); // logo path ( iis express doesn't have project root in Url var baseUrl = cntlr.Request.Url.GetLeftPart(UriPartial.Authority); string logoPng = String.Format("{0}{1}{2}{3}" , baseUrl , cntlr.Request.Url.Segments[0] , cntlr.Request.Url.Segments[1].IndexOf(controllerName) == 0 ? String.Empty : cntlr.Request.Url.Segments[1] , DpWebAppConfig.Emblem_Logo); cntlr.ViewBag.Logo = Graphics.GetImgTag(logoPng, "logo"); // Service Type AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(consularApptVM.AppointmentType); cntlr.ViewBag.AppointmentType = appointmentType.Description; ViewRenderer vr = new ViewRenderer(cntlr.ControllerContext); return(vr.RenderPartialView(Template_ConfirmedEmail, consularApptVM)); }
public async Task <ActionResult> Create([Bind(Include = "AppointmentDate,AppointmentType,Name,Gender,DateOfBirth,PlaceOfBirth,Nationality,NRIC_No,PassportNumber,PassportIssuedDate,ConsulateLocation,StayType,StayPermitNumber,EmployerName,Occupation,ContactAddr1,ContactAddr2,ContactPhone,ContactEmail,HomeAddr1,HomeAddr2,HomePhone,Note")] ConsularApptVM consularApptVM) { if (!Request.IsAuthenticated) { ViewBag.Title = "Embassy Consular Appointment Form"; EmbassyAppDb.AddConsularAppt(consularApptVM, EmWebAppConfig.QueueNumberInitial); Email email = this.GetConfirmationRequestEmail(consularApptVM); using (var smtp = new SmtpClient()) { smtp.Prep(); await smtp.SendMailAsync(email.Message); } ViewBag.PartialHtml = "_MsgApptReceived"; } else { ViewBag.Title = "Embassy Consular Appointment Form (Admin)"; consularApptVM.Note = "[ADMIN]" + consularApptVM.Note; EmbassyAppDb.AddConsularAppt(consularApptVM, EmWebAppConfig.QueueNumberInitial); DateTime? confirmedApptDate = null; int? confirmedQueNumber = 0; ConsularApptVM consularApptVM2 = EmbassyAppDb.ConfirmConsularAppt(consularApptVM.Id, consularApptVM.ActivationCode, ref confirmedApptDate, ref confirmedQueNumber); consularApptVM.QueueNumber = confirmedQueNumber.GetValueOrDefault(); ViewBag.PartialHtml = "_MsgApptConfirmedByAdmin"; } AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(consularApptVM.AppointmentType); ViewBag.AppointmentType = appointmentType.Description; return(View(consularApptVM)); }
public async Task <ActionResult> ConfirmPosted(string confirmedId, string confirmedCode) { if (!Request.IsAjaxRequest()) { return(Content("Request Error.")); } int id = int.Parse(confirmedId); string code = confirmedCode; DateTime? confirmedApptDate = null; int? confirmedQueNumber = 0; ConsularApptVM consularApptVM = EmbassyAppDb.ConfirmConsularAppt(id, code, ref confirmedApptDate, ref confirmedQueNumber); if (consularApptVM == null) { return(RedirectToAction("Error")); } string confirmedEmailBody = this.GetConfirmedEmailBody(consularApptVM); string confirmationLetter = this.GetConfirmationLetter(consularApptVM); // To do: Maybe convert the confirmationLetter to PDF, or get fillable PDF letter // Get Required Form Attachment List AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(consularApptVM.AppointmentType); List <BLL.Attachment> formAttachments = appointmentType.Attachments?.List; // Start preparing for Email Email embassyMail = new Email { From = EmWebAppConfig.EmailAddress, DisplayName = EmWebAppConfig.EmailUser, To = consularApptVM.ContactEmail, Subject = EmWebAppConfig.EmailSubj_Confirmed, Body = confirmedEmailBody, IsHtml = true }; // using (MemoryStream ms = new MemoryStream()) string pdfTemplateFile = ConfirmationLetterPdf.GetPdfTemplateFileName(appointmentType, consularApptVM.StayType); using (MemoryStream ms = ConfirmationLetterPdf.GetAppointmentLetterStream(pdfTemplateFile, consularApptVM)) using (MailMessage mailMsg = embassyMail.Message) using (var smtp = new SmtpClient()) { System.Net.Mail.Attachment coverLetterPdf = Email.GetPdfAttachmentFromPdfStream(ms, "AppointmentLetter.pdf"); // System.Net.Mail.Attachment coverLetterPdf = Email.GetPdfAttachmentFromHtmlString(confirmationLetter, ms, "AppointmentLetter.pdf"); mailMsg.Attachments.Add(coverLetterPdf); if (formAttachments != null) { foreach (var attachment in formAttachments) { if (System.IO.File.Exists(attachment.FullPath)) { var emailAttachment = new System.Net.Mail.Attachment(attachment.FullPath, new ContentType(MediaTypeNames.Application.Pdf)); mailMsg.Attachments.Add(emailAttachment); } } } smtp.Prep(); await smtp.SendMailAsync(mailMsg); // return View(consularApptVM); return(PartialView("_MsgApptConfirmed", consularApptVM)); } }