public IEnumerable <SecurityDetail> GetSecurityClaims() { try { List <tblBooking> list = _dbEntity.tblBookings.Where(x => (x.IsAccidentalClaimRaised == true || x.IsTheftClaimRaised == true) && x.IsSecurityAmountPaid == true && !string.IsNullOrEmpty(x.SecurityId) && x.IsSecurityCaptureOrRefund == false).ToList(); List <SecurityDetail> securityDetailList = new List <SecurityDetail>(); foreach (tblBooking tblBooking in list) { SecurityDetail securityDetail1 = new SecurityDetail(); securityDetail1.Id = tblBooking.BookingId; string bookingId = tblBooking.BookingId.ToString(); securityDetail1.BookingId = bookingId; string empty = string.Empty; DateTime dateTime; if (tblBooking.IsTheftClaimRaised == true) { securityDetail1.TypeOfClaim = "Theft Report"; string appSetting = ConfigurationManager.AppSettings["TheftClaimPdf"]; tblTheftClaim tblTheftClaim = _dbEntity.tblTheftClaims.Where(x => x.BookingId == bookingId).FirstOrDefault(); if (tblTheftClaim != null) { securityDetail1.PDF = appSetting + tblTheftClaim.PDFName; SecurityDetail securityDetail2 = securityDetail1; dateTime = Convert.ToDateTime((object)tblTheftClaim.CreatedDate); string str = dateTime.ToString("MM-dd-yyyy hh:mm tt"); securityDetail2.CreatedDate = str; } } else if (tblBooking.IsAccidentalClaimRaised == true) { securityDetail1.TypeOfClaim = "Accidental Claim"; string appSetting = ConfigurationManager.AppSettings["AccidentalClaimPdf"]; tblAccidentalClaim tblAccidentalClaim = _dbEntity.tblAccidentalClaims .Where(x => x.BookingId == bookingId).FirstOrDefault(); if (tblAccidentalClaim != null) { securityDetail1.PDF = appSetting + tblAccidentalClaim.PDFName; SecurityDetail securityDetail2 = securityDetail1; dateTime = Convert.ToDateTime(tblAccidentalClaim.CreatedDate); string str = dateTime.ToString("MM-dd-yyyy hh:mm tt"); securityDetail2.CreatedDate = str; } } securityDetailList.Add(securityDetail1); } return(securityDetailList); } catch (Exception ex) { Common.ExcepLog(ex); throw; } }
public string RejectAccidentalClaimById(long id) { try { tblAccidentalClaim tblAccidentalClaim = db.tblAccidentalClaims.FirstOrDefault(x => x.Id == id); if (tblAccidentalClaim == null) return string.Empty; string host = ConfigurationManager.AppSettings["Host"]; string from = ConfigurationManager.AppSettings["FromEmail"]; string password = ConfigurationManager.AppSettings["Password"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]); MailMessage messageToUser = new MailMessage(); string str1 = System.IO.File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath("~/EmailTemplate"), "MailTemplate.html")).Replace("{UserName}", tblAccidentalClaim.FullName + " ,").Replace("{Message}", "Your Accidental claim form regarding Booking Ref :" + tblAccidentalClaim.BookingId + " has been rejected by the Admin<br/>").Replace("{Link}", string.Empty); string email = tblAccidentalClaim.Email; string str2 = "BiblioVélo:: Accidental Claim Rejected"; messageToUser.From = new MailAddress(from, "BiblioVélo Support"); messageToUser.To.Add(email); messageToUser.Subject = str2; messageToUser.IsBodyHtml = true; messageToUser.Body = str1; SmtpClient smtpClient1 = new SmtpClient(host, port); smtpClient1.EnableSsl = true; smtpClient1.Credentials = new NetworkCredential(from, password); try { smtpClient1.Send(messageToUser); } catch (SmtpException ex1) { Common.ExcepLog(ex1); } this.db.tblAccidentalClaims.Remove(tblAccidentalClaim); this.db.SaveChanges(); return "deleted"; } catch (Exception ex) { Common.ExcepLog(ex); return string.Empty; } }
public long AddAccidentalClaim(AccidentalClaimModel accidentalModel) { try { tblBooking tblBooking = db.tblBookings.FirstOrDefault(x => x.BookingId == Convert.ToInt32(accidentalModel.BookingId)); if (tblBooking != null) { tblBooking.IsAccidentalClaimRaised = new bool?(true); tblBooking.IsRenterRaisedDispute = new bool?(true); db.SaveChanges(); } } catch (Exception Ex) { } string tempPath = System.IO.Path.Combine(HostingEnvironment.MapPath("~/PdfTemplates"), "AccidentalClaimPDF.html"); string _pdfContent = System.IO.File.ReadAllText(tempPath); _pdfContent = _pdfContent.Replace("{fullname}", accidentalModel.FullName); _pdfContent = _pdfContent.Replace("{email}", accidentalModel.Email); _pdfContent = _pdfContent.Replace("{dob}", accidentalModel.DOB); _pdfContent = _pdfContent.Replace("{booking}", accidentalModel.BookingId); _pdfContent = _pdfContent.Replace("{address}", accidentalModel.Address); _pdfContent = _pdfContent.Replace("{postcode}", accidentalModel.PostCode); _pdfContent = _pdfContent.Replace("{mobilenumber}", accidentalModel.MobileNumber); _pdfContent = _pdfContent.Replace("{dateofincident}", accidentalModel.DateOfIncident); _pdfContent = _pdfContent.Replace("{timeofincident}", accidentalModel.TimeOfIncident); _pdfContent = _pdfContent.Replace("{incharge}", accidentalModel.InCharge); _pdfContent = _pdfContent.Replace("{incidentdetails}", accidentalModel.IncidentDescription); _pdfContent = _pdfContent.Replace("{witnessdetails}", accidentalModel.WitnessDetails); _pdfContent = _pdfContent.Replace("{thirdpartydetails}", accidentalModel.ThirdPartyDetails); _pdfContent = _pdfContent.Replace("{reportedtopolice}", accidentalModel.IsReportedToPolice == true ? "Yes" : "No"); _pdfContent = _pdfContent.Replace("{anotherinsurer}", accidentalModel.IsAnotherInsurer == true ? "Yes" : "No"); _pdfContent = _pdfContent.Replace("{refused}", accidentalModel.IsRefusedRenewal == true ? "Yes" : "No"); _pdfContent = _pdfContent.Replace("{itemclaims}", accidentalModel.ItemsClaimedFor); _pdfContent = _pdfContent.Replace("{circumstances}", accidentalModel.Circumstances); _pdfContent = _pdfContent.Replace("{previousinsurer}", accidentalModel.PreviousInsurerName); _pdfContent = _pdfContent.Replace("{expirydate}", accidentalModel.ExpiryDate); _pdfContent = _pdfContent.Replace("{pastclaims}", accidentalModel.PastClaimDetails); _pdfContent = _pdfContent.Replace("{criminalconvictions}", accidentalModel.IsAnyCriminalConviction == true ? "Yes" : "No"); _pdfContent = _pdfContent.Replace("{policycancelled}", accidentalModel.IsPolicyCancelled == true ? "Yes" : "No"); _pdfContent = _pdfContent.Replace("{providedetails}", accidentalModel.ProvidedDetails); TextWriter _fWriter = new StreamWriter(HostingEnvironment.MapPath("~/Templates/dfTemplate.htm")); _fWriter.Write(_pdfContent); _fWriter.Close(); _fWriter.Dispose(); PdfConverter pdfConverter = new PdfConverter(); pdfConverter.LicenseKey = "elFLWktaTE9IWk9USlpJS1RLSFRDQ0ND"; pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.Letter; pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.NoCompression; pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Landscape; pdfConverter.PdfDocumentOptions.BottomMargin = 20; pdfConverter.PdfDocumentOptions.TopMargin = 20; pdfConverter.PdfDocumentOptions.LeftMargin = 20; pdfConverter.PdfDocumentOptions.RightMargin = 20; pdfConverter.PdfDocumentOptions.ShowHeader = false; pdfConverter.PdfDocumentOptions.ShowFooter = false; pdfConverter.PdfDocumentOptions.AutoSizePdfPage = false; pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true; pdfConverter.PdfDocumentOptions.SinglePage = true; byte[] pdfBytes = pdfConverter.GetPdfBytesFromUrl(HostingEnvironment.MapPath("~/Templates/dfTemplate.htm")); string pdfName = RandomString(7) + ".pdf"; accidentalModel.PDFName = pdfName; System.IO.File.WriteAllBytes(HostingEnvironment.MapPath("~/PdfTemplates/AccidentalClaimForms/" + pdfName), pdfBytes); Mapper.Initialize(new MapperConfigurationExpression() { AllowNullCollections = true, AllowNullDestinationValues = true, CreateMissingTypeMaps = true }); tblAccidentalClaim accidental = Mapper.Instance.Map<tblAccidentalClaim>(accidentalModel); accidental.IsApproved = false; accidental.CreatedDate = DateTime.Now; db.tblAccidentalClaims.Add(accidental); db.SaveChanges(); return accidental.Id; }
public string ApproveAccidentalClaimById(long id) { try { string str1 = HostingEnvironment.MapPath("~/PdfTemplates/AccidentalClaimForms/"); string appSetting = ConfigurationManager.AppSettings["AccidentalClaimBackupPath"]; tblAccidentalClaim tblAccidentalClaim = db.tblAccidentalClaims.FirstOrDefault(x => x.Id == id); if (tblAccidentalClaim == null) return string.Empty; string host = ConfigurationManager.AppSettings["Host"]; string from = ConfigurationManager.AppSettings["FromEmail"]; string insurerEmail = ConfigurationManager.AppSettings["InsurerEmail"]; string password = ConfigurationManager.AppSettings["Password"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]); string str2 = str1 + tblAccidentalClaim.PDFName; string requestUri = appSetting + tblAccidentalClaim.PDFName; if (System.IO.File.Exists(str2)) { MailMessage message = new MailMessage(); string str3 = System.IO.File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath("~/EmailTemplate"), "MailTemplate.html")).Replace("Hi", "Dear").Replace("{UserName}", "Sir/Mam,").Replace("{Message}", "We have sent you an accidental claim form .<br/>Please find attached PDF").Replace("{Link}", string.Empty); message.Attachments.Add(new Attachment(str2) { ContentDisposition = { Inline = true } }); message.From = new MailAddress(from, "BiblioVélo Support"); message.To.Add(insurerEmail); message.Subject = "BiblioVélo::Accidental Claim Form"; message.IsBodyHtml = true; message.Body = str3; SmtpClient smtpClient = new SmtpClient(host, port); smtpClient.EnableSsl = true; smtpClient.Credentials = (ICredentialsByHost)new NetworkCredential(from, password); try { smtpClient.Send(message); } catch (SmtpException ex1) { Common.ExcepLog((Exception)ex1); } } MailMessage messageToUser = new MailMessage(); string str4 = System.IO.File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath("~/EmailTemplate"), "MailTemplate.html")).Replace("{UserName}", tblAccidentalClaim.FullName + " ,").Replace("{Message}", "Your Accidental claim form regarding Booking Ref :" + tblAccidentalClaim.BookingId + " has been approved by the Admin and send it to the insurer for further inquiry.<br/>").Replace("{Link}", string.Empty); string email = tblAccidentalClaim.Email; string str5 = "BiblioVélo:: Accidental Claim Approved"; messageToUser.From = new MailAddress(from, "BiblioVélo Support"); messageToUser.To.Add(email); messageToUser.Subject = str5; messageToUser.IsBodyHtml = true; messageToUser.Body = str4; SmtpClient smtpClient1 = new SmtpClient(host, port); smtpClient1.EnableSsl = true; smtpClient1.Credentials = new NetworkCredential(from, password); try { smtpClient1.Send(messageToUser); } catch (SmtpException ex1) { Common.ExcepLog(ex1); } tblAccidentalClaim.IsApproved = new bool?(true); this.db.SaveChanges(); return "deleted"; } catch (Exception ex) { Common.ExcepLog(ex); return string.Empty; } }