public static IEnumerable <PriceChangeHistory> GetFilter(IEnumerable <PriceChangeHistory> priceChangeHistory, ChartTimeType chartTimeType) { switch (chartTimeType) { case ChartTimeType.Last7Days: return(GetLast7Days(priceChangeHistory)); case ChartTimeType.LastMonth: return(GetLastMonth(priceChangeHistory)); case ChartTimeType.FromBeginning: return(priceChangeHistory); default: return(GetThisMonth(priceChangeHistory)); } }
public static IEnumerable <PriceChangeItem> GetFilter(IEnumerable <PriceChangeHistory> priceChangeHistory, ChartTimeType chartTimeType, DateTime?createdDate) { var priceHistory = priceChangeHistory.GroupBy(i => i.DateStamp.Date).Select(i => new PriceChangeItem { ChangedDate = i.Key, ChangedPrice = i.OrderByDescending(j => j.DateStamp).FirstOrDefault().NewSalePrice }).ToList(); if (createdDate.HasValue) { priceHistory.Add(new PriceChangeItem { ChangedDate = createdDate.Value, ChangedPrice = priceChangeHistory.OrderBy(i => i.DateStamp).Select(i => i.OldSalePrice).FirstOrDefault() }); } switch (chartTimeType) { case ChartTimeType.Last7Days: return(GetLast7Days(priceHistory)); case ChartTimeType.LastMonth: return(GetLastMonth(priceHistory)); case ChartTimeType.FromBeginning: return(GetPriceList(priceHistory, priceHistory.Min(i => i.ChangedDate).Date, GetMaxDate(priceHistory.Max(i => i.ChangedDate), DateTime.Now.Date), DateTime.Now.Date)); default: case ChartTimeType.ThisMonth: return(GetThisMonth(priceHistory)); } }
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)); }