Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        private static string GetAppraisalName(string name)
        {
            var context = new whitmanenterprisewarehouseEntities();
            var user    = (from u in context.whitmanenterpriseusers
                           where u.UserName == name
                           select u).FirstOrDefault();

            if (user != null)
            {
                return(user.Name);
            }
            else
            {
                var masterUser = (from u in context.whitmanenterprisedealergroups
                                  where u.MasterUserName == name
                                  select u).FirstOrDefault();
                if (masterUser != null)
                {
                    return(masterUser.DealerGroupName);
                }
                else
                {
                    return(String.Empty);
                }
            }
        }
Esempio n. 3
0
        public static AppraisalViewFormModel GetAppraisalModelFromAppriaslId(int appraisalId)
        {
            var context = new whitmanenterprisewarehouseEntities();
            var row     = context.whitmanenterpriseappraisals.FirstOrDefault(x => x.idAppraisal == appraisalId);

            return(row == null ? new AppraisalViewFormModel() : new AppraisalViewFormModel(row));
        }
        void YearDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            var context      = new whitmanenterprisewarehouseEntities();
            var selectedYear = 0;

            int.TryParse(YearDropDownList.SelectedValue, out selectedYear);
            var firstMakeList  = InventoryQueryHelper.GetSingleOrGroupInventory(context).Where(x => x.ModelYear == selectedYear).Select(x => x.Make).ToList();
            var secondMakeList = InventoryQueryHelper.GetSingleOrGroupSoldoutInventory(context).Where(x => x.ModelYear == selectedYear).Select(x => x.Make);

            firstMakeList.AddRange(secondMakeList);

            var makeList = new List <string>();

            makeList.Insert(0, string.Empty);

            var hashSet = new HashSet <string>();

            foreach (var tmp in firstMakeList)
            {
                var makeName = tmp.ToLower();

                if (!hashSet.Contains(makeName))
                {
                    makeList.Add(tmp);
                }

                hashSet.Add(makeName);
            }


            MakeDropDownList.DataSource = makeList;
            MakeDropDownList.DataBind();
            ModelDropDownList.Items.Clear();
        }
Esempio n. 5
0
        public List <KBBInfo> GetProfitManagement()
        {
            var context = new whitmanenterprisewarehouseEntities();
            var result  =
                from i in InventoryQueryHelper.GetSingleOrGroupInventory(context)
                join k in context.whitmanenterprisekbbs.Where(j => j.Type == Constanst.VehicleTable.Inventory)
                on new { i.KBBTrimId, i.VINNumber } equals new { KBBTrimId = k.TrimId, VINNumber = k.Vin }
            into gj
            from g in gj.DefaultIfEmpty()
            where i.NewUsed == "Used"
            select new KBBInfo
            {
                VIN            = i.VINNumber,
                StockNumber    = i.StockNumber,
                DateInStock    = i.DateInStock.Value,
                Year           = i.ModelYear ?? 0,
                Make           = i.Make,
                Model          = i.Model,
                Trim           = i.Trim,
                WholeSale      = g.WholeSale,
                DealerCost     = String.IsNullOrEmpty(i.DealerCost) ? "NA" : i.DealerCost,
                DealershipName = i.DealershipName,
            };
            var sorted = result.ToList();

            foreach (var kbbInfo in sorted)
            {
                kbbInfo.DaysInInvenotry = DateTime.Now.Subtract(kbbInfo.DateInStock).Days;
                GetCost(kbbInfo);
            }


            return(sorted.OrderByDescending(i => i.KBBCost).ThenByDescending(i => i.Year).ThenBy(i => i.Make).ThenBy(i => i.Model).ToList());
        }
Esempio n. 6
0
 private vincontroldescriptiontemplate GetTemplate(int templateId)
 {
     using (var context = new whitmanenterprisewarehouseEntities())
     {
         return(context.vincontroldescriptiontemplates.FirstOrDefault(i => i.Id == templateId));
     }
 }
Esempio n. 7
0
        public List <VinControlVehicleReport> GetNext7DaysBucketJumpVehicles(int dealerId)
        {
            var mProducts = new List <VinControlVehicleReport>();

            var context = new whitmanenterprisewarehouseEntities();

            IQueryable <whitmanenterprisedealershipinventory> avaiInventory =
                from e in InventoryQueryHelper.GetSingleOrGroupInventory(context)
                where e.NewUsed.ToLower().Equals("used") && (e.Recon == null || !((bool)e.Recon))
                select e;

            var dtDealerSetting = InventoryQueryHelper.GetSingleOrGroupSetting(context).ToList();

            var dtDealerInfo = InventoryQueryHelper.GetSingleOrGroupDealer(context).ToList();

            for (int i = 1; i <= 7; i++)
            {
                foreach (var tmp in avaiInventory.OrderBy(x => x.Make))
                {
                    int daysInInvenotry = DateTime.Now.AddDays(i).Subtract(tmp.DateInStock.GetValueOrDefault()).Days;

                    bool flag = dtDealerSetting.FirstOrDefault(item => tmp.DealershipId == item.DealershipId).IntervalBucketJump != 0 && ((daysInInvenotry == dtDealerSetting.FirstOrDefault(item => tmp.DealershipId == item.DealershipId).FirstTimeRangeBucketJump) || (daysInInvenotry == dtDealerSetting.FirstOrDefault(item => tmp.DealershipId == item.DealershipId).SecondTimeRangeBucketJump) || ((daysInInvenotry - dtDealerSetting.FirstOrDefault(item => tmp.DealershipId == item.DealershipId).SecondTimeRangeBucketJump) % dtDealerSetting.FirstOrDefault(item => tmp.DealershipId == item.DealershipId).IntervalBucketJump) == 0);

                    if (flag)
                    {
                        var v = new VinControlVehicleReport
                        {
                            AutoId          = mProducts.Count + 1,
                            ModelYear       = tmp.ModelYear.GetValueOrDefault(),
                            Make            = String.IsNullOrEmpty(tmp.Make) ? "" : tmp.Make,
                            Model           = String.IsNullOrEmpty(tmp.Model) ? "" : tmp.Model,
                            Trim            = String.IsNullOrEmpty(tmp.Trim) ? "" : tmp.Trim,
                            StockNumber     = String.IsNullOrEmpty(tmp.StockNumber) ? "" : tmp.StockNumber,
                            Vin             = String.IsNullOrEmpty(tmp.VINNumber) ? "" : tmp.VINNumber,
                            Mileage         = String.IsNullOrEmpty(tmp.Mileage) ? "" : tmp.Mileage,
                            ExteriorColor   = String.IsNullOrEmpty(tmp.ExteriorColor) ? "" : tmp.ExteriorColor,
                            SalePrice       = String.IsNullOrEmpty(tmp.SalePrice) ? "" : tmp.SalePrice,
                            DaysInInvenotry = DateTime.Now.Subtract(tmp.DateInStock.Value).Days,
                            DealershipName  = String.IsNullOrEmpty(dtDealerInfo.FirstOrDefault(item => tmp.DealershipId == item.idWhitmanenterpriseDealership).DealershipName)
                                                 ? ""
                                                 : dtDealerInfo.FirstOrDefault(item => tmp.DealershipId == item.idWhitmanenterpriseDealership).DealershipName,
                            Engine = String.IsNullOrEmpty(tmp.EngineType) ? "" : tmp.EngineType,
                            Style  = String.IsNullOrEmpty(tmp.BodyType) ? "" : tmp.BodyType,
                            Date   = new DateTime(DateTime.Now.AddDays(i).Year, DateTime.Now.AddDays(i).Month, DateTime.Now.AddDays(i).Day)
                        };


                        if (v.Engine.Contains("Engine"))
                        {
                            v.Engine = v.Engine.Replace("Engine", "");
                        }


                        mProducts.Add(v);
                    }
                }
            }

            return(mProducts);
        }
Esempio n. 8
0
        public static BlackBookViewModel GetBBModelInDatabase(string Vin)
        {
            BlackBookViewModel dealerPrice = new BlackBookViewModel()
            {
                Vin            = Vin,
                TrimReportList = new List <BlackBookTrimReport>()
            };
            int status = SQLHelper.CheckVinHasBbReport(Vin);

            if (status == 1)
            {
                var context = new whitmanenterprisewarehouseEntities();

                var list = context.whitmanenterprisebbs.Where(x => x.Vin.Equals(Vin));

                foreach (whitmanenterprisebb bb in list)
                {
                    BlackBookTrimReport TrimReport = new BlackBookTrimReport()
                    {
                        TradeInRough = CommonHelper.ConvertToCurrency(bb.TradeInFairPrice),
                        TradeInAvg   = CommonHelper.ConvertToCurrency(bb.TradeInGoodPrice),
                        TradeInClean = CommonHelper.ConvertToCurrency(bb.TradeInVeryGoodPrice),
                        TrimName     = bb.Trim
                    };
                    dealerPrice.TrimReportList.Add(TrimReport);
                    dealerPrice.ExistDatabase = status;
                }
            }
            else
            {
                dealerPrice.ExistDatabase = status;
            }
            return(dealerPrice);
        }
        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());
        }
Esempio n. 10
0
        public static CarInfoFormViewModel GetVehicleInfoForEbay(int listingId, int dealershipId)
        {
            var context = new whitmanenterprisewarehouseEntities();

            var row = context.whitmanenterprisedealershipinventories.First(x => x.ListingID == listingId);

            return(row == null ? new CarInfoFormViewModel() : new CarInfoFormViewModel(row, dealershipId));
        }
Esempio n. 11
0
 public bool AllowAutoDescription(whitmanenterprisedealershipinventory inventory, int dealerId)
 {
     using (var context = new whitmanenterprisewarehouseEntities())
     {
         var setting = context.whitmanenterprisesettings.FirstOrDefault(i => i.DealershipId == dealerId);
         return(inventory != null && (inventory.EnableAutoDescription.GetValueOrDefault() || inventory.EnableAutoDescription == null) && setting != null && (setting.AutoDescription.GetValueOrDefault()) ? true : false);
     }
 }
Esempio n. 12
0
 public void GenerateAutoDescription(int newListingId)
 {
     using (var context = new whitmanenterprisewarehouseEntities())
     {
         AssignAutoDescription(newListingId);
         //_context.SaveChanges();
     }
 }
Esempio n. 13
0
 private vincontroldescriptiontemplate GetRandomizedTemplate(InventoryStatus inventoryStatus)
 {
     using (var context = new whitmanenterprisewarehouseEntities())
     {
         var random          = new Random();
         var status          = inventoryStatus.ToString();
         var activeTemplates = context.vincontroldescriptiontemplates.Where(i => i.IsActive && i.Type.Equals(status));
         int randomElement   = random.Next(0, activeTemplates.Count());
         return(activeTemplates.ToList().ElementAt(randomElement));
     }
 }
Esempio n. 14
0
        public static IQueryable <whitmanenterprisesetting> GetSingleOrGroupSetting(whitmanenterprisewarehouseEntities context)
        {
            if (!SessionHandler.Single)
            {
                return(context.whitmanenterprisesettings.Where(
                           LogicHelper.BuildContainsExpression
                           <whitmanenterprisesetting, int>(
                               e => e.DealershipId.Value, GetDealerList(context))));
            }

            return(context.whitmanenterprisesettings.Where(e => e.DealershipId == SessionHandler.Dealership.DealershipId));
        }
Esempio n. 15
0
        public static IQueryable <vincontrolbuyerguide> GetSingleOrGroupBuyerGuide(whitmanenterprisewarehouseEntities context)
        {
            if (!SessionHandler.Single)
            {
                return(context.vincontrolbuyerguides.Where(
                           LogicHelper.BuildContainsExpression
                           <vincontrolbuyerguide, int>(
                               e => e.dealershipId.Value, GetDealerList(context))));
            }

            return(context.vincontrolbuyerguides.Where(e => e.dealershipId == SessionHandler.Dealership.DealershipId));
        }
Esempio n. 16
0
        public static IEnumerable <PriceChangeItem> GetPriceChangeListForChart(string listingId, ChartTimeType type, DateTime createdDate, int inventoryStatus)
        {
            var priceChangeList = new List <PriceChangeHistory>();

            using (var context = new whitmanenterprisewarehouseEntities())
            {
                var convertedListingId = Convert.ToInt32(listingId);
                if (inventoryStatus == 1)
                {
                    var history =
                        context.vincontrolpricechangeshistories.Where(
                            i => i.ListingId == convertedListingId && i.Type.ToLower().Equals("inventory")).ToList();
                    if (history.Count > 0)
                    {
                        priceChangeList = history.Select(i => new PriceChangeHistory()
                        {
                            AttachFile   = i.AttachFile,
                            UserStamp    = i.UserStamp,
                            DateStamp    = i.DateStamp.Value,
                            NewSalePrice = i.NewPrice.Value,
                            OldSalePrice = i.OldPrice.Value,
                            ListingId    = i.ListingId.Value
                        }).ToList();
                    }
                }
                else
                {
                    var soldCard =
                        context.whitmanenterprisedealershipinventorysoldouts.First(i => i.ListingID == convertedListingId);

                    if (soldCard.OldListingId.GetValueOrDefault() > 0)
                    {
                        var history =
                            context.vincontrolpricechangeshistories.Where(
                                i => i.ListingId == soldCard.OldListingId && i.Type.ToLower().Equals("inventory")).ToList();
                        if (history.Count > 0)
                        {
                            priceChangeList = history.Select(i => new PriceChangeHistory()
                            {
                                AttachFile   = i.AttachFile,
                                UserStamp    = i.UserStamp,
                                DateStamp    = i.DateStamp.Value,
                                NewSalePrice = i.NewPrice.Value,
                                OldSalePrice = i.OldPrice.Value,
                                ListingId    = i.ListingId.Value
                            }).ToList();
                        }
                    }
                }
            }
            return(GetFilter(priceChangeList, type, createdDate));
        }
Esempio n. 17
0
 public bool AllowAutoDescription(int dealerId)
 {
     using (var context = new whitmanenterprisewarehouseEntities())
     {
         var setting = context.whitmanenterprisesettings.FirstOrDefault(i => i.DealershipId == dealerId);
         if (setting != null)
         {
             return(setting.AutoDescriptionSubscribe.GetValueOrDefault() &&
                    setting.AutoDescription.GetValueOrDefault());
         }
         return(false);
     }
 }
Esempio n. 18
0
        private static IEnumerable <int> GetDealerList(whitmanenterprisewarehouseEntities context)
        {
            if (SessionHandler.IsMaster)
            {
                return(from e in context.whitmanenterprisedealerships
                       where
                       e.DealerGroupID ==
                       SessionHandler.DealerGroup.DealershipGroupId
                       select e.idWhitmanenterpriseDealership);
            }

            return(SessionHandler.DealerGroup.DealerList.Select(i => i.DealershipId));
        }
Esempio n. 19
0
        public static IQueryable <vincontrolbannercustomer> GetSingleOrGroupTradein(whitmanenterprisewarehouseEntities context)
        {
            if (!SessionHandler.Single)
            {
                return
                    (context.vincontrolbannercustomers.Where(
                         LogicHelper.BuildContainsExpression
                         <vincontrolbannercustomer, int>(
                             e => e.DealerId.Value, GetDealerList(context))));
            }

            return(context.vincontrolbannercustomers.Where(e => e.DealerId == SessionHandler.Dealership.DealershipId));
        }
Esempio n. 20
0
 public static DateTime?GetCreatedDate(string listingId, int inventoryStatus)
 {
     using (var context = new whitmanenterprisewarehouseEntities())
     {
         int id = int.Parse(listingId);
         if (inventoryStatus == 1)
         {
             return(context.whitmanenterprisedealershipinventories.Where(i => i.ListingID == id).Select(i => i.DateInStock).FirstOrDefault());
         }
         else
         {
             return(context.whitmanenterprisedealershipinventorysoldouts.Where(i => i.ListingID == id).Select(i => i.DateInStock).FirstOrDefault());
         }
     }
 }
Esempio n. 21
0
        public static IEnumerable <string> GetEmailsForInventoryNotification(int dealerId)
        {
            using (var context = new whitmanenterprisewarehouseEntities())
            {
                var result =
                    from e in context.whitmanenterpriseusersnotifications
                    from et in context.whitmanenterpriseusers
                    where
                    e.DealershipId == dealerId && e.InventoryNotification.Value && et.Active.Value && e.UserName == et.UserName

                    select new
                {
                    et.Email,
                };

                return(result.Select(x => x.Email).AsEnumerable());
            }
        }
Esempio n. 22
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);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var context        = new whitmanenterprisewarehouseEntities();
                var firstYearList  = InventoryQueryHelper.GetSingleOrGroupInventory(context).Select(x => x.ModelYear).ToList();
                var secondYearList = InventoryQueryHelper.GetSingleOrGroupSoldoutInventory(context).Select(x => x.ModelYear);

                firstYearList.AddRange(secondYearList);

                var yearList = new List <string>();

                yearList.Insert(0, string.Empty);

                yearList.AddRange(firstYearList.Distinct().OrderByDescending(i => i.Value).ToList().Select(i => i.Value.ToString()).ToList());

                YearDropDownList.DataSource = yearList;
                YearDropDownList.DataBind();
            }
        }
Esempio n. 24
0
        public List <VehiclePriceChange> GetHistoryChanged(int dealerId, int month, int year, string make, string model, string stock, string vin)
        {
            var context        = new whitmanenterprisewarehouseEntities();
            var finalInventory = (context.vincontrolpricechangeshistories.Where(GetMonthQuery(month)).Join(InventoryQueryHelper.GetSingleOrGroupInventory(context).Where(i => i.DealershipId == dealerId).Where(GetYearQuery(year)).Where(GetMakeQuery(make)).Where(GetModelQuery(model)).Where(GetStockQuery(stock)).Where(GetVinQuery(vin)), p => p.ListingId, i => i.ListingID,
                                                                                                           (p, i) => new VehiclePriceChange()
            {
                Make = i.Make,
                Model = i.Model,
                Month = p.DateStamp.Value.Month,
                OldPrice = (long)p.OldPrice.Value,
                Price = (long)p.NewPrice.Value,
                StockNumber = i.StockNumber,
                UpdatedDate = p.DateStamp.Value,
                User = p.UserStamp,
                VINNumber = i.VINNumber,
                DealershipName = i.DealershipName,
                Year = i.ModelYear ?? 0
            })).OrderBy(x => x.Make).ThenBy(x => x.UpdatedDate).ToList();

            var soldInventory = (context.vincontrolpricechangeshistories.Where(GetMonthQuery(month)).Join(InventoryQueryHelper.GetSingleOrGroupSoldoutInventory(context).Where(i => i.DealershipId == dealerId).Where(GetYearQueryForSold(year)).Where(GetMakeQueryForSold(make)).Where(GetModelQueryForSold(model)).Where(GetStockQueryForSold(stock)).Where(GetVinQueryForSold(vin)), p => p.ListingId, i => i.OldListingId,
                                                                                                          (p, i) => new VehiclePriceChange()
            {
                Make = i.Make,
                Model = i.Model,
                Month = p.DateStamp.Value.Month,
                OldPrice = (long)p.OldPrice.Value,
                Price = (long)p.NewPrice.Value,
                StockNumber = i.StockNumber,
                UpdatedDate = p.DateStamp.Value,
                User = p.UserStamp,
                VINNumber = i.VINNumber,
                DealershipName = i.DealershipName,
                Year = i.ModelYear ?? 0
            })).OrderBy(x => x.Make).ThenBy(x => x.UpdatedDate).ToList();

            finalInventory.AddRange(soldInventory);

            return(finalInventory);
        }
Esempio n. 25
0
        //public static void ExportToCSV<T>(this IQueryable<T> list, string filename, string[] exclude)
        //{
        //    StringWriter sw = new StringWriter();
        //    bool headerPrinted = false;
        //    foreach (var obj in list)
        //    {
        //        Type type = obj.GetType();
        //        PropertyInfo[] properties = type.GetProperties();

        //        string s = String.Empty;
        //        if (!headerPrinted)
        //        {
        //            foreach (PropertyInfo propertyInfo in properties)
        //            {
        //                if (exclude.Count(x => x.Contains(propertyInfo.Name)) > 0)
        //                    continue;

        //                if (s.Length > 0)
        //                    s = String.Join(",", new string[] { s, propertyInfo.Name });
        //                else
        //                    s = propertyInfo.Name;
        //            }
        //            sw.WriteLine(s);
        //            headerPrinted = true;
        //        }

        //        s = String.Empty;
        //        for (int idx = 0; idx < properties.Length; idx++)
        //        {

        //            if (exclude.Count(x => x.Contains(properties[idx].Name)) > 0)
        //                continue;

        //            var value = properties[idx].GetValue(obj, null);
        //            var formattedValue = value == null ? String.Empty : value.ToString();

        //            if (value != null)
        //            {
        //                if (value.GetType() == typeof(string))
        //                    formattedValue = "\"" + formattedValue + "\"";
        //            }

        //            if (s.Length > 0)
        //                s = String.Join(",", new string[] { s, formattedValue });
        //            else
        //                s = formattedValue;

        //        }
        //        sw.WriteLine(s);
        //    }
        //    HttpResponse response = System.Web.HttpContext.Current.Response;
        //    response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
        //    response.ContentType = "application/ms-excel";
        //    response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
        //    response.Write(sw);
        //    response.End();
        //}

        public static byte[] ExportToCSV(List <CarInfoFormViewModel> carList, int dealerId, string Title)
        {
            var package = new ExcelPackage();
            // add a new worksheet to the empty workbook
            var worksheet = package.Workbook.Worksheets.Add(Title);

            WriteHeader(worksheet);
            //Switch the PageLayoutView back to normal
            // lets set the header text
            worksheet.HeaderFooter.oddHeader.CenteredText = "&24&U&\"Arial,Regular Bold\"" + Title;
            // add the page number to the footer plus the total number of pages
            worksheet.HeaderFooter.oddFooter.RightAlignedText =
                string.Format("Page {0} of {1}", ExcelHeaderFooter.PageNumber, ExcelHeaderFooter.NumberOfPages);
            // add the sheet name to the footer
            worksheet.HeaderFooter.oddFooter.CenteredText = ExcelHeaderFooter.SheetName;
            // add the file path to the footer

            worksheet.PrinterSettings.RepeatRows    = worksheet.Cells["1:1"];
            worksheet.PrinterSettings.RepeatColumns = worksheet.Cells["A:G"];

            package.Workbook.Properties.Title = Title;

            worksheet = package.Workbook.Worksheets[1];

            int numberOfRow = worksheet.Dimension.End.Row - worksheet.Dimension.Start.Row;
            int startRow    = numberOfRow + 2;

            var context         = new whitmanenterprisewarehouseEntities();
            var dtDealerSetting = context.whitmanenterprisesettings.FirstOrDefault(x => x.DealershipId == dealerId);


            //PlUG DATA
            startRow = PlugData(carList.Where(x => !x.Reconstatus).OrderBy(x => x.Make), worksheet, dtDealerSetting.DefaultStockImageUrl, startRow, false);
            PlugData(carList.Where(x => x.Reconstatus).OrderBy(x => x.Make), worksheet, dtDealerSetting.DefaultStockImageUrl, startRow, true);

            return(package.GetAsByteArray());
        }
Esempio n. 26
0
        private string GetRandomizedSentence(int typeId, string dealershipName)
        {
            using (var context = new whitmanenterprisewarehouseEntities())
            {
                var random = new Random();
                if (context.vincontrolsentences.Any(i => i.typeId == typeId))
                {
                    var activeSentences = context.vincontrolsentences.Where(i => i.typeId == typeId);
                    int randomElement   = random.Next(0, activeSentences.Count());
                    var returnSentence  = activeSentences.ToList().ElementAt(randomElement).sentence;

                    if (returnSentence.Contains("[Dealership]"))
                    {
                        returnSentence = returnSentence.Replace("[Dealership]", dealershipName);
                    }

                    return(returnSentence);
                }
                else
                {
                    return(string.Empty);
                }
            }
        }
Esempio n. 27
0
        public static TradeInVehicleModel GetTradeinVehicle(int id)
        {
            var     context  = new whitmanenterprisewarehouseEntities();
            var     customer = context.vincontrolbannercustomers.Where(e => e.TradeInCustomerId == id).FirstOrDefault();
            decimal result;

            TradeInVehicleModel vehicle = new TradeInVehicleModel()
            {
                Condition          = customer.Condition,
                CustomerEmail      = customer.Email,
                CustomerFirstName  = customer.FirstName,
                CustomerLastName   = customer.LastName,
                CustomerPhone      = customer.Phone,
                SelectedMake       = customer.Make,
                SelectedModel      = customer.Model,
                SelectedTrim       = customer.Trim,
                SelectedYear       = customer.Year.HasValue ? customer.Year.Value.ToString() : String.Empty,
                Mileage            = customer.Mileage.HasValue ? customer.Mileage.Value.ToString() : String.Empty,
                SelectedOptionList = customer.SelectedOptions,
                TradeInFairPrice   = decimal.TryParse(customer.TradeInFairValue, out result) ? result.ToString("c0") : customer.TradeInFairValue
            };

            return(vehicle);
        }
Esempio n. 28
0
        private void UploadImage(HttpContext context, bool saveImage)
        {
            string dealerId = context.Request.QueryString["DealerId"];
            string vin      = context.Request.QueryString["Vin"];
            int    overlay  = Convert.ToInt32(context.Request.QueryString["Overlay"]);

            string fileName = context.Request.QueryString["uploadedfile"];

            string imageFileName = fileName;
            //string imageFileName = ListingId + "-" + FileName;

            ImageDirectories imageDirectories = CreateFolder(dealerId, vin);
            string           resultFileName   = imageDirectories.FullSizeDirectory.FullName + "/" + imageFileName + ".jpg";

            using (FileStream fileStream = File.Create(resultFileName))
            {
                var bytes = new byte[4096]; //100MB max
                int totalBytesRead;
                while ((totalBytesRead = context.Request.InputStream.Read(bytes, 0, bytes.Length)) != 0)
                {
                    fileStream.Write(bytes, 0, totalBytesRead);
                }
            }

            var image = ProcessImage(dealerId, vin, overlay, imageFileName, imageDirectories.FullSizeDirectory, imageDirectories.ThumbnailDirectory);

            if (saveImage)
            {
                int listingId = int.Parse(context.Request.QueryString["ListingId"].ToString(CultureInfo.InvariantCulture));
                using (var dbContext = new whitmanenterprisewarehouseEntities())
                {
                    var row =
                        dbContext.whitmanenterprisedealershipinventories.FirstOrDefault(x => x.ListingID == listingId);
                    if (row != null)
                    {
                        if (String.IsNullOrEmpty(row.CarImageUrl))
                        {
                            row.CarImageUrl = image.FileUrl;
                        }
                        else
                        {
                            row.CarImageUrl = row.CarImageUrl + ',' + image.FileUrl;
                        }

                        if (String.IsNullOrEmpty(row.ThumbnailImageURL))
                        {
                            row.ThumbnailImageURL = image.ThumbnailUrl;
                        }
                        else
                        {
                            row.ThumbnailImageURL = row.ThumbnailImageURL + ',' + image.ThumbnailUrl;
                        }



                        row.LastUpdated = DateTime.Now;

                        dbContext.SaveChanges();
                    }
                }
            }


            var js = new JavaScriptSerializer();

            context.Response.Write(js.Serialize(image));
        }
Esempio n. 29
0
        //
        // GET: /Switch/

        public ActionResult SwitchDealership(CarInfoFormViewModel switchModel)
        {
            try
            {
                if (Session["DealerGroup"] != null)
                {
                    var dealerGroup = (DealerGroupViewModel)Session["DealerGroup"];
                    if (switchModel.SelectedDealerTransfer.Equals("999"))
                    {
                        SessionHandler.Single     = false;
                        Session["DealershipName"] = dealerGroup.DealershipGroupName;
                        return(Json("Success"));
                    }



                    var switchDealer = dealerGroup.DealerList.First(t => t.DealershipId.ToString(CultureInfo.InvariantCulture).Equals(switchModel.SelectedDealerTransfer));

                    using (var context = new whitmanenterprisewarehouseEntities())
                    {
                        var setting = context.whitmanenterprisesettings.FirstOrDefault(x => x.DealershipId == switchDealer.DealershipId);

                        switchDealer.DealerGroupId    = dealerGroup.DealershipGroupId;
                        switchDealer.InventorySorting = setting.InventorySorting;

                        switchDealer.SoldOut = setting.SoldOut;

                        switchDealer.DefaultStockImageUrl    = setting.DefaultStockImageUrl;
                        switchDealer.OverrideStockImage      = setting.OverideStockImage.Value;
                        switchDealer.OverrideDealerKbbReport = switchDealer.OverrideDealerKbbReport;
                        switchDealer.DealerInfo = setting.DealerInfo;

                        switchDealer.DealerWarranty = setting.DealerWarranty;

                        switchDealer.TermConditon = setting.TermsAndCondition;

                        switchDealer.EbayToken = setting.EbayToken;

                        switchDealer.EbayInventoryUrl = setting.EbayInventoryURL;

                        switchDealer.CreditUrl = setting.CreditURL;

                        switchDealer.WebSiteUrl = setting.WebSiteURL;

                        switchDealer.ContactUsUrl = setting.ContactUsURL;

                        switchDealer.FacebookUrl = setting.FacebookURL;

                        switchDealer.LogoUrl = setting.LogoURL;

                        switchDealer.ContactPerson = setting.ContactUsURL;

                        switchDealer.CarFax = setting.CarFax;

                        switchDealer.CarFaxPassword = setting.CarFaxPassword;

                        switchDealer.Manheim = setting.Manheim;

                        switchDealer.ManheimPassword = setting.ManheimPassword;

                        switchDealer.KellyBlueBook = setting.KellyBlueBook;

                        switchDealer.KellyPassword = setting.KellyPassword;

                        switchDealer.BlackBook = setting.BlackBook;

                        switchDealer.BlackBookPassword = setting.BlackBookPassword;

                        switchDealer.IntervalBucketJump = setting.IntervalBucketJump.GetValueOrDefault();

                        switchDealer.FirstIntervalJump = setting.FirstTimeRangeBucketJump.GetValueOrDefault();

                        switchDealer.SecondIntervalJump = setting.SecondTimeRangeBucketJump.GetValueOrDefault();

                        switchDealer.LoanerSentence = setting.LoanerSentence;

                        switchDealer.AuctionSentence = setting.AuctionSentence;

                        SessionHandler.Single = true;
                        Session["Dealership"] = switchDealer;

                        Session["DealershipName"] = switchDealer.DealershipName;
                    }


                    return(Json("Success"));
                }
                else
                {
                    return(Json("SessionTimeOut"));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.ToString()));
            }
        }
Esempio n. 30
0
        public static IQueryable <whitmanenterprisedealership> GetSingleOrGroupDealer(whitmanenterprisewarehouseEntities context)
        {
            if (!SessionHandler.Single)
            {
                return(context.whitmanenterprisedealerships.Where(
                           LogicHelper.BuildContainsExpression
                           <whitmanenterprisedealership, int>(
                               e => e.idWhitmanenterpriseDealership, GetDealerList(context))));
            }

            return(context.whitmanenterprisedealerships.Where(e => e.idWhitmanenterpriseDealership == SessionHandler.Dealership.DealershipId));
        }