Пример #1
0
        public static AppraisalViewFormModel GetAppraisalViewModel(string vin)
        {
            var viewModel = new AppraisalViewFormModel();

            var autoService = new ChromeAutoService();

            var vehicleInfo = autoService.GetVehicleInformationFromVin(vin);

            if (vehicleInfo != null)
            {
                viewModel = ConvertHelper.GetVehicleInfoFromChromeDecode(vehicleInfo);

                viewModel.AppraisalDate = DateTime.Now.ToShortDateString();
            }

            if (viewModel.IsTruck)
            {
                viewModel.TruckTypeList = SelectListHelper.InitalTruckTypeList();

                viewModel.TruckCategoryList = SelectListHelper.InitalTruckCategoryList(SQLHelper.GetListOfTruckCategoryByTruckType(viewModel.TruckTypeList.First().Value));

                viewModel.TruckClassList = SelectListHelper.InitalTruckClassList();
            }
            return(viewModel);
        }
Пример #2
0
        private string GetMSRPFromChrome(string vinNumber)
        {
            var autoService = new ChromeAutoService();
            var vehicleInfo = autoService.GetVehicleInformationFromVin(vinNumber);

            return(vehicleInfo.basePrice.msrp.high.ToString());
        }
Пример #3
0
        public static JavaScriptModel GetJavaScripModel(string vin, DealershipViewModel dealer)
        {
            var autoService = new ChromeAutoService();
            var model       = new JavaScriptModel();

            if (SQLHelper.CheckVinExist(vin, dealer))
            {
                var context = new whitmanenterprisewarehouseEntities();
                var row     = context.whitmanenterprisedealershipinventories.FirstOrDefault(x => x.VINNumber == vin && x.DealershipId == dealer.DealershipId);
                model.ListingId = row.ListingID.ToString(CultureInfo.InvariantCulture);
                model.Status    = "Inventory";
            }
            else if (SQLHelper.CheckVinExistInSoldOut(vin, dealer))
            {
                var context = new whitmanenterprisewarehouseEntities();
                var row     = context.whitmanenterprisedealershipinventorysoldouts.FirstOrDefault(x => x.VINNumber == vin && x.DealershipId == dealer.DealershipId);
                model.ListingId = row.ListingID.ToString(CultureInfo.InvariantCulture);
                model.Status    = "SoldOut";
            }
            else if (SQLHelper.CheckVinExistInAppraisal(vin, dealer))
            {
                var context = new whitmanenterprisewarehouseEntities();
                var row     = context.whitmanenterpriseappraisals.FirstOrDefault(x => x.VINNumber == vin && x.DealershipId == dealer.DealershipId);
                model.AppraisalId = row.idAppraisal.ToString(CultureInfo.InvariantCulture);
                model.Status      = "Appraisal";
                //return RedirectToAction("ViewProfileForAppraisal", "Appraisal", new { AppraisalId = row["AppraisalID"].ToString() });
            }
            else
            {
                var vehicleInfo = autoService.GetVehicleInformationFromVin(vin);
                if (vehicleInfo != null)
                {
                    model.Vin    = vin;
                    model.Status = "VinProcessing";
                }
                else
                {
                    model.Vin    = vin;
                    model.Status = "VinInvalid";
                }
            }

            return(model);
        }
Пример #4
0
        public static InspectionAppraisalViewModel GetPendingAppraisal(int id)
        {
            var model = new InspectionAppraisalViewModel();
            //try
            //{
            var receivedAppraisalId = Convert.ToInt32(id);

            using (var context = new whitmanenterprisewarehouseEntities())
            {
                var existingAppraisal = context.whitmanenterpriseappraisals.Where(a => a.idAppraisal == receivedAppraisalId).FirstOrDefault();
                if (existingAppraisal != null)
                {
                    model.AppraisalInfo = new AppraisalInfo()
                    {
                        AppraisalId     = existingAppraisal.idAppraisal,
                        VinNumber       = existingAppraisal.VINNumber ?? "",
                        StockNumber     = existingAppraisal.StockNumber ?? "",
                        Year            = existingAppraisal.ModelYear ?? 2012,
                        Make            = existingAppraisal.Make ?? "",
                        Model           = existingAppraisal.Model ?? "",
                        Trim            = existingAppraisal.Trim ?? "",
                        ExteriorColor   = existingAppraisal.ExteriorColor ?? "",
                        InteriorColor   = existingAppraisal.InteriorColor ?? "",
                        Transmission    = existingAppraisal.Tranmission ?? "",
                        Odometer        = existingAppraisal.Mileage ?? "",
                        Cylinders       = existingAppraisal.Cylinders ?? "",
                        Liters          = existingAppraisal.Liters ?? "",
                        Doors           = existingAppraisal.Doors ?? "",
                        Fuel            = existingAppraisal.FuelType ?? "",
                        MSRP            = existingAppraisal.MSRP ?? "",
                        DriveType       = existingAppraisal.DriveTrain ?? "",
                        ImageUrl        = existingAppraisal.DefaultImageUrl,
                        Photo           = existingAppraisal.Photo,
                        Options         = String.IsNullOrEmpty(existingAppraisal.CarsOptions) ? new List <string>() : existingAppraisal.CarsOptions.Split(',').ToList(),
                        Packages        = String.IsNullOrEmpty(existingAppraisal.CarsPackages) ? new List <string>() : existingAppraisal.CarsPackages.Split(',').ToList(),
                        StandardOptions = String.IsNullOrEmpty(existingAppraisal.StandardOptions) ? new List <string>() : existingAppraisal.StandardOptions.Split(',').ToList(),
                        AppraisalDate   = existingAppraisal.DateStamp.HasValue ? existingAppraisal.DateStamp.Value.ToShortDateString() : String.Empty,
                        AppraisalTime   = existingAppraisal.DateStamp.HasValue ? existingAppraisal.DateStamp.Value.ToShortTimeString() : String.Empty,
                        EngineType      = existingAppraisal.EngineType,
                        AppraisalBy     = GetAppraisalName(existingAppraisal.UserStamp)
                    };

                    var autoService = new ChromeAutoService();
                    if (!(String.IsNullOrEmpty(model.AppraisalInfo.VinNumber)) && model.AppraisalInfo.VinNumber != "None")
                    {
                        var vehicleInfo = autoService.GetVehicleInformationFromVin(model.AppraisalInfo.VinNumber);
                        model.AppraisalInfo.StandardOptions = InitializeOptions(vehicleInfo.standard).Select(o => o.Text).ToList();
                    }
                    else
                    {
                        IdentifiedString[] divisionList = autoService.GetDivisions(model.AppraisalInfo.Year);
                        var make        = SelectListHelper.InitialMakeList(divisionList).Where(m => m.Text.Equals(model.AppraisalInfo.Make)).First();
                        var chromeModel = autoService.GetModelsByDivision(model.AppraisalInfo.Year, Convert.ToInt32(make.Value.Split('|')[0])).Where(m => m.Value.Equals(model.AppraisalInfo.Model)).FirstOrDefault();
                        if (chromeModel != null)
                        {
                            var styles    = autoService.GetStyles(chromeModel.id);
                            int styleId   = Convert.ToInt32(styles.First().id);
                            var styleInfo = autoService.GetStyleInformationFromStyleId(styleId);
                            model.AppraisalInfo.StandardOptions = InitializeOptions(styleInfo.standard).Select(o => o.Text).ToList();
                        }
                    }

                    model.CustomerInfo = new CustomerInfo()
                    {
                        FirstName = existingAppraisal.FirstName,
                        LastName  = existingAppraisal.LastName,
                        Phone     = existingAppraisal.Phone,
                        Email     = existingAppraisal.Email,
                        City      = existingAppraisal.City,
                        State     = existingAppraisal.State,
                        Zip       = existingAppraisal.ZipCode,
                        Street    = existingAppraisal.Street,
                        Signature = existingAppraisal.Signature
                    };

                    var walkarounds = context.vincontrolwalkarounds.Where(i => i.whitmanenterpriseappraisal.idAppraisal == receivedAppraisalId).OrderBy(i => i.order).ToList();
                    if (walkarounds.Count > 0)
                    {
                        model.WalkaroundInfo = walkarounds.Select(w => new WalkaroundInfo()
                        {
                            Order = w.order ?? 0,
                            Note  = GetNoteContent(w.note, w.order),
                            X     = w.x ?? 0,
                            Y     = w.y ?? 0
                        });
                    }

                    //var answers =
                    //    context.vincontrolanswers.Where(i => i.whitmanenterpriseappraisal.idAppraisal == receivedAppraisalId).Select(
                    //        a => new AppraisalAnswer()
                    //        {
                    //            Question = a.vincontrolquestions.shortdescription,
                    //            Answer = a.answer,
                    //            Comment = a.comment,
                    //            QuestionType = a.vincontrolquestions.vincontrolquestiontype.code??4
                    //        }).ToList();

                    var answers =
                        context.vincontrolanswers.Where(i => i.whitmanenterpriseappraisal.idAppraisal == receivedAppraisalId).Select(
                            a => new
                    {
                        QuestionId   = a.vincontrolquestion.questionid,
                        Question     = a.vincontrolquestion.shortdescription,
                        Answer       = a.answer,
                        Comment      = a.comment,
                        QuestionType = a.vincontrolquestion.vincontrolquestiontype.code ?? 4,
                        Order        = a.vincontrolquestion.order
                    }).ToList();
                    //AppraisalAnswer()
                    var questions = context.vincontrolquestions.Include("vincontrolquestiontype");
                    var list      = new List <AppraisalAnswer>();
                    foreach (var question in questions)
                    {
                        var answer = answers.FirstOrDefault(a => a.QuestionId == question.questionid);
                        if (answer != null)
                        {
                            list.Add(new AppraisalAnswer()
                            {
                                Question     = answer.Question,
                                Answer       = GetAnswer(answer.Answer, question.vincontrolquestiontype.unit),
                                Comment      = GetShortString(answer.Comment),
                                QuestionType = answer.QuestionType,
                                Order        = answer.Order ?? 0
                            });
                        }
                        else
                        {
                            list.Add(new AppraisalAnswer()
                            {
                                Question     = question.shortdescription,
                                Answer       = String.Empty,
                                Comment      = String.Empty,
                                QuestionType = question.vincontrolquestiontype.code ?? 4,
                                Order        = question.order ?? 0
                            });
                        }
                    }

                    if (answers.Count > 0)
                    {
                        model.AppraisalAnswer = list.OrderBy(o => o.Order);
                    }
                    else
                    {
                        model.AppraisalAnswer = list;
                    }
                }
            }
            //}
            //catch (Exception)
            //{

            //}

            return(model);
        }