//public List<Vehical_Details> VehicleListModel { get; set; } //public List<SummaryVehicleDetailsModel> SummaryVehicleDetailsModel { get; set; } public ReVehical_Details() { CustomerModel = new CustomersDetailsModel(); PolicyDetail = new PolicyDetail(); objPolicyDetailModel = new PolicyDetailModel(); RiskDetailModel = new RiskDetailModel(); //RiskDetailModel = new RiskDetailModel(); SummaryDetailModel = new SummaryDetailModel(); }
public int AddVehicleInformation(RiskDetailModel model) { try { model = GetCoverStartDateEndDate(model); if (model.RenewalDate.Year == 1) // handling the exception { model.CoverStartDate = DateTime.Now; if (model.PaymentTermId == 1) { model.CoverEndDate = DateTime.Now.AddMonths(12); } else { model.CoverEndDate = DateTime.Now.AddMonths(model.PaymentTermId); } model.RenewalDate = model.CoverEndDate.Value.AddDays(1); model.TransactionDate = DateTime.Now; model.PolicyExpireDate = model.CoverEndDate.ToString(); } var db = Mapper.Map <RiskDetailModel, VehicleDetail>(model); db.IsActive = true; db.CreatedOn = DateTime.Now; db.ManufacturerYear = DateTime.Now.ToShortDateString(); InsuranceContext.VehicleDetails.Insert(db); return(db.Id); } catch (Exception ex) { LogDetailTbl log = new LogDetailTbl(); log.VRN = model.RegistrationNo; log.Request = "ALM " + ex.Message; string vehicleInfo = model.RegistrationNo + "," + model.PaymentTermId + "," + model.CoverTypeId + "," + model.CoverStartDate + "," + model.CoverEndDate + "," + model.VehicleYear + "," + model.Premium + ","; vehicleInfo += model.StampDuty + "," + model.ZTSCLevy + "," + model.Discount + "," + model.IncludeRadioLicenseCost + "," + model.RadioLicenseCost + "," + model.VehicleLicenceFee + "," + model.PolicyId; log.Response = vehicleInfo; InsuranceContext.LogDetailTbls.Insert(log); return(0); } }
public RiskDetailModel GetCoverStartDateEndDate(RiskDetailModel model) { model.CoverStartDate = DateTime.Now; if (model.PaymentTermId == 1) { model.CoverEndDate = DateTime.Now.AddMonths(12); } else { model.CoverEndDate = DateTime.Now.AddMonths(model.PaymentTermId); } model.RenewalDate = model.CoverEndDate.Value.AddDays(1); model.TransactionDate = DateTime.Now; model.PolicyExpireDate = model.CoverEndDate.ToString(); return(model); }
//public static string AddLoyaltyPoints(int CustomerId, int PolicyId, RiskDetailModel vehicle, string email = "", string filepath = "") public static string AddLoyaltyPoints(int CustomerId, int PolicyId, RiskDetailModel vehicle, string currencyName, string email = "", string filepath = "") { var loaltyPointsSettings = InsuranceContext.Settings.Single(where : $"keyname='Points On Renewal'"); var loyaltyPoint = 0.00m; switch (vehicle.PaymentTermId) { case 1: if (loaltyPointsSettings.ValueType == Convert.ToInt32(eSettingValueType.percentage)) { loyaltyPoint = ((Convert.ToDecimal(vehicle.AnnualRiskPremium) * Convert.ToDecimal(loaltyPointsSettings.value)) / 100); } if (loaltyPointsSettings.ValueType == Convert.ToInt32(eSettingValueType.amount)) { loyaltyPoint = Convert.ToDecimal(loaltyPointsSettings.value); } break; case 3: if (loaltyPointsSettings.ValueType == Convert.ToInt32(eSettingValueType.percentage)) { loyaltyPoint = ((Convert.ToDecimal(vehicle.QuaterlyRiskPremium) * Convert.ToDecimal(loaltyPointsSettings.value)) / 100); } if (loaltyPointsSettings.ValueType == Convert.ToInt32(eSettingValueType.amount)) { loyaltyPoint = Convert.ToDecimal(loaltyPointsSettings.value); } break; case 4: if (loaltyPointsSettings.ValueType == Convert.ToInt32(eSettingValueType.percentage)) { loyaltyPoint = ((Convert.ToDecimal(vehicle.TermlyRiskPremium) * Convert.ToDecimal(loaltyPointsSettings.value)) / 100); } if (loaltyPointsSettings.ValueType == Convert.ToInt32(eSettingValueType.amount)) { loyaltyPoint = Convert.ToDecimal(loaltyPointsSettings.value); } break; } LoyaltyDetail objLoyaltydetails = new LoyaltyDetail(); objLoyaltydetails.CustomerId = CustomerId; objLoyaltydetails.IsActive = true; objLoyaltydetails.PolicyId = PolicyId; objLoyaltydetails.PointsEarned = loyaltyPoint; objLoyaltydetails.CreatedBy = CustomerId; objLoyaltydetails.CreatedOn = DateTime.Now; InsuranceContext.LoyaltyDetails.Insert(objLoyaltydetails); EmailService objEmailService = new EmailService(); bool userLoggedin = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated; var policy = InsuranceContext.PolicyDetails.Single(PolicyId); var customer = InsuranceContext.Customers.Single(CustomerId); var TotalLoyaltyPoints = InsuranceContext.LoyaltyDetails.All(where : $"CustomerId={CustomerId}").Sum(x => x.PointsEarned); string ReminderEmailPath = "/Views/Shared/EmaiTemplates/LoyaltyPoints.cshtml"; string EmailBody2 = System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath(ReminderEmailPath)); //var body = EmailBody2.Replace("##FirstName##", customer.FirstName).Replace("##path##", filepath).Replace("##LastName##", customer.LastName).Replace("##CreditedWalletAmount##", Convert.ToString(loyaltyPoint)).Replace("##TotalWalletBalance##", Convert.ToString(TotalLoyaltyPoints)); var body = EmailBody2.Replace("##FirstName##", customer.FirstName).Replace("##path##", filepath).Replace("##LastName##", customer.LastName).Replace("##Currency##", Convert.ToString(currencyName)).Replace("##CreditedWalletAmount##", Convert.ToString(loyaltyPoint)).Replace("##TotalWalletBalance##", Convert.ToString(TotalLoyaltyPoints)); // var yAtter = "~/Pdf/14809 Gene Insure Motor Policy Book.pdf"; var attacheMentPath = MiscellaneousService.EmailPdf(body, policy.CustomerId, policy.PolicyNumber, "Loyalty Points"); List <string> attachements = new List <string>(); attachements.Add(attacheMentPath); //if (!userLoggedin) //{ // attachements.Add(yAtter); // objEmailService.SendEmail(email, "", "", "Loyalty Reward | Points Credited to your Wallet", body, attachements); //} objEmailService.SendEmail(email, "", "", "Loyalty Reward | Points Credited to your Wallet", body, attachements); return(""); }