public JsonResult GetCarFaxReport(int appraisalId) { var carfax = new CarFaxViewModel() { Success = false }; if (Session["Dealership"] == null) { return(new DataContractJsonResult(carfax)); } var contextVinControl = new whitmanenterprisewarehouseEntities(); var targetCar = contextVinControl.whitmanenterpriseappraisals.First( (x => x.idAppraisal == appraisalId)); var dealer = (DealershipViewModel)Session["Dealership"]; carfax = CarFaxHelper.ConvertXmlToCarFaxModelAndSave(targetCar.VINNumber, dealer.CarFax, dealer.CarFaxPassword); return(new DataContractJsonResult(carfax)); }
public string GenerateFlyerStringContent(Inventory inventory) { ICarFaxService _carFaxService = new CarFaxService(); try { { var inventoryViewModel = inventory == null ? new CarInfoFormViewModel() : new CarInfoFormViewModel(inventory); if (inventoryViewModel.Condition == Constanst.ConditionStatus.Used) { try { inventoryViewModel.CarFax = _carFaxService.ConvertXmlToCarFaxModelAndSave(inventory.Vehicle.VehicleId, inventory.Vehicle.Vin, inventory.Dealer.Setting.CarFax, inventory.Dealer.Setting.CarFaxPassword); } catch (Exception) { } } else { var carfax = new CarFaxViewModel { ReportList = new List <CarFaxWindowSticker>(), Success = false }; inventoryViewModel.CarFax = carfax; } //string htmlToConvert = RenderRazorViewToString(new FakeController(), "Flyer", inventoryViewModel); return(""); } } catch (Exception) { return(String.Empty); } }
public static CarFaxViewModel GetCarFaxReportInDatabase(string Vin) { var carfax = new CarFaxViewModel { ReportList = new List <CarFaxWindowSticker>() }; int status = SQLHelper.CheckVinHasCarFaxReport(Vin); if (status == 1) { var context = new whitmanenterprisewarehouseEntities(); var tmp = context.whitmanenteprisecarfaxes.First(x => x.Vin.Equals(Vin)); try { carfax.Vin = tmp.Vin; carfax.NumberofOwners = tmp.Owner.ToString(); carfax.ServiceRecords = tmp.ServiceRecord; carfax.AccidentCounts = tmp.Accident.GetValueOrDefault(); carfax.PriorRental = tmp.PriorRental.GetValueOrDefault(); var stringList = tmp.WindowSticker.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (carfax.AccidentCounts > 0) { carfax.ReportList.Add(new CarFaxWindowSticker() { Text = carfax.AccidentCounts + " Accident(s) / Damage Reported to CARFAX", Image = "http://vincontrol.com/alpha/content/CarfaxWarning.jpg" }); } if (carfax.PriorRental) { carfax.ReportList.Add(new CarFaxWindowSticker() { Text = "Prior Rental", Image = "http://vincontrol.com/alpha/content/CarfaxWarning.jpg" }); } foreach (string c in stringList) { var pair = c.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries); var sticker = new CarFaxWindowSticker() { Text = pair.First(), Image = pair.Last() }; carfax.ReportList.Add(sticker); } carfax.ExistDatabase = status; } catch (Exception) { carfax.ExistDatabase = status; } } else { carfax.ExistDatabase = status; } return(carfax); }