public static string BuildWindowStickerInHtml() { var context = new whitmanenterprisewarehouseEntities(); var rows = InventoryQueryHelper.GetSingleOrGroupInventory(context).Where(x => x.NewUsed.ToLower().Equals("used") && (x.Recon == null || !((bool)x.Recon))); var settingRow = InventoryQueryHelper.GetSingleOrGroupSetting(context); var builder = new StringBuilder(); builder.AppendLine(" <!DOCTYPE html>"); builder.AppendLine("<html>"); builder.AppendLine("<head>"); builder.AppendLine("<title></title>"); builder.AppendLine("</head>"); builder.AppendLine("<body>"); builder.AppendLine("<font face=\"Trebuchet MS\">"); foreach (var row in rows) { BuildWindowStickerBody(builder, row, settingRow.FirstOrDefault(i => row.DealershipId == i.DealershipId)); } builder.AppendLine("</font>"); builder.AppendLine("</body>"); builder.AppendLine("</html>"); return(builder.ToString()); }
public static string BuildBuyerGuideInHTML(ControllerContext controllerContext) { var context = new whitmanenterprisewarehouseEntities(); var rows = InventoryQueryHelper.GetSingleOrGroupInventory(context).Where(x => x.NewUsed.ToLower().Equals("used") && (x.Recon == null || !((bool)x.Recon))); var settingRow = InventoryQueryHelper.GetSingleOrGroupSetting(context); var buyerGuideList = InventoryQueryHelper.GetSingleOrGroupBuyerGuide(context).Where(bg => bg.LanguageVersion == 1).ToList(); var returnList = new List <AdminBuyerGuideViewModel>(); foreach (var row in rows) { var adminBuyerGuideViewModel = new AdminBuyerGuideViewModel(); var warrantyType = 0; if (row.WarrantyInfo == null) { warrantyType = 1; } else { warrantyType = row.WarrantyInfo.GetValueOrDefault(); } var buyerGuideSetting = buyerGuideList.FirstOrDefault(bg => bg.warrantyType == warrantyType && bg.dealershipId == row.DealershipId); adminBuyerGuideViewModel.SelectedLanguage = 1; if (buyerGuideSetting != null) { adminBuyerGuideViewModel.Id = buyerGuideSetting.buyerguideid; adminBuyerGuideViewModel.Vin = String.IsNullOrEmpty(row.VINNumber) ? "NA" : row.VINNumber; adminBuyerGuideViewModel.Year = row.ModelYear.GetValueOrDefault().ToString(); adminBuyerGuideViewModel.Make = String.IsNullOrEmpty(row.Make) ? "NA" : row.Make; adminBuyerGuideViewModel.VehicleModel = String.IsNullOrEmpty(row.Model) ? "NA" : row.Model; adminBuyerGuideViewModel.StockNumber = String.IsNullOrEmpty(row.StockNumber) ? "NA" : row.StockNumber; adminBuyerGuideViewModel.WarrantyType = buyerGuideSetting.warrantyType.GetValueOrDefault(); adminBuyerGuideViewModel.ServiceContract = buyerGuideSetting.isServiceContract ?? false; adminBuyerGuideViewModel.IsAsWarranty = buyerGuideSetting.isAsWarranty ?? false; adminBuyerGuideViewModel.IsWarranty = buyerGuideSetting.isWarranty ?? false; adminBuyerGuideViewModel.IsFullWarranty = buyerGuideSetting.isFullWarranty ?? false; adminBuyerGuideViewModel.IsLimitedWarranty = buyerGuideSetting.isLimitedWarranty ?? false; adminBuyerGuideViewModel.IsServiceContract = buyerGuideSetting.isServiceContract ?? false; adminBuyerGuideViewModel.IsMixed = buyerGuideSetting.isMixed ?? false; adminBuyerGuideViewModel.SystemCovered = ReplaceFontSizeForBuyerGuideReport(buyerGuideSetting.systemCovered); adminBuyerGuideViewModel.SystemCoveredAndDurations = ReplaceFontSizeForBuyerGuideReport(buyerGuideSetting.systemCoveredAndDurations); adminBuyerGuideViewModel.Durations = ReplaceFontSizeForBuyerGuideReport(buyerGuideSetting.durations); adminBuyerGuideViewModel.PercentageOfLabor = buyerGuideSetting.percentageOfLabor ?? 0; adminBuyerGuideViewModel.PercentageOfPart = buyerGuideSetting.percentageOfPart ?? 0; adminBuyerGuideViewModel.PriorRental = row.PriorRental.GetValueOrDefault() ? "PRIOR RENTAL" : ""; adminBuyerGuideViewModel.IsPriorRental = row.PriorRental.GetValueOrDefault(); } else { adminBuyerGuideViewModel.Vin = String.IsNullOrEmpty(row.VINNumber) ? "NA" : row.VINNumber; adminBuyerGuideViewModel.Year = row.ModelYear.GetValueOrDefault().ToString(); adminBuyerGuideViewModel.Make = String.IsNullOrEmpty(row.Make) ? "NA" : row.Make; adminBuyerGuideViewModel.VehicleModel = String.IsNullOrEmpty(row.Model) ? "NA" : row.Model; adminBuyerGuideViewModel.StockNumber = String.IsNullOrEmpty(row.StockNumber) ? "NA" : row.StockNumber; adminBuyerGuideViewModel.ServiceContract = false; adminBuyerGuideViewModel.IsAsWarranty = String.IsNullOrEmpty(settingRow.FirstOrDefault(i => row.DealershipId == i.DealershipId).AsIsWarranty) ? false : true; adminBuyerGuideViewModel.IsWarranty = warrantyType != 1 ? true : false; adminBuyerGuideViewModel.IsFullWarranty = false; adminBuyerGuideViewModel.IsLimitedWarranty = false; adminBuyerGuideViewModel.IsServiceContract = false; adminBuyerGuideViewModel.SystemCovered = string.Empty; adminBuyerGuideViewModel.Durations = String.IsNullOrEmpty(settingRow.FirstOrDefault(i => row.DealershipId == i.DealershipId).ManufacturerWarrantyDuration) ? "" : settingRow.FirstOrDefault(i => row.DealershipId == i.DealershipId).ManufacturerWarrantyDuration; adminBuyerGuideViewModel.PercentageOfLabor = 100; adminBuyerGuideViewModel.PercentageOfPart = 100; adminBuyerGuideViewModel.PriorRental = row.PriorRental.GetValueOrDefault() ? "PRIOR RENTAL" : ""; adminBuyerGuideViewModel.IsPriorRental = row.PriorRental.GetValueOrDefault(); if (!adminBuyerGuideViewModel.IsWarranty && !adminBuyerGuideViewModel.IsFullWarranty && !adminBuyerGuideViewModel.IsLimitedWarranty) { adminBuyerGuideViewModel.IsAsWarranty = true; } } returnList.Add(adminBuyerGuideViewModel); } string htmlToConvert = PDFHelper.RenderViewAsString("BuyerGuideBody", returnList, controllerContext); return(htmlToConvert); }