public static DataTable GetNewHomesForSaleForCSV(string searchText, string sortField, bool sortDirection, Filters filterList = new Filters()) { string cachingFilterText = GetCacheFilterText(filterList.GetCustomFilterList(), searchText); DataTable objects; string baseKey = cacheKeyPrefix + "GetNewHomesForSaleForCSV_" + cachingFilterText; string key = baseKey + "_" + sortField + "_" + sortDirection; string countKey = baseKey + "_count"; DataTable tmpList = null; int? tmpInt = null; if (Cache.IsEnabled) { tmpList = Cache[key] as DataTable; tmpInt = Cache[countKey] as int?; } if (tmpList != null && tmpInt.HasValue) { objects = tmpList; m_ItemCount = tmpInt.Value; } else { List <ShowcaseItem> reportItems = GetNewHomesForSale(searchText, sortField, sortDirection, filterList).OrderBy(s => s.Neighborhood != null ? s.Neighborhood.Name : "zzz").ThenBy(s => s.NumberOfVisits).ToList(); List <string> columnNames = new List <string> { "Neighborhood", "MLS ID", "Market", "Agent", "List Date", "Address", "Price", "Builder" }; objects = new DataTable(); foreach (string column in columnNames) { objects.Columns.Add(column); } List <ClickType> clickTypes = ClickType.GetAll(); foreach (ClickType clickType in clickTypes) { objects.Columns.Add(clickType.Name + " Clicks"); } foreach (ShowcaseItem obj in reportItems) { DataRow dr = objects.NewRow(); dr["Neighborhood"] = obj.Neighborhood != null ? obj.Neighborhood.Name : string.Empty; dr["MLS ID"] = obj.MlsID; dr["Market"] = obj.ShowcaseID == (int)MeybohmShowcases.AikenExistingHomes ? "Aiken" : "Augusta"; dr["Agent"] = obj.AgentInfo != null ? obj.AgentInfo.FirstAndLast : string.Empty; dr["List Date"] = obj.DateListed.HasValue ? obj.DateListed.Value.ToShortDateString() : string.Empty; dr["Address"] = obj.Address != null ? obj.Address.Address1 : string.Empty; dr["Price"] = obj.ListPrice.HasValue ? obj.ListPrice.Value.ToString("C") : string.Empty; dr["Builder"] = obj.Builder != null ? obj.Builder.Name : string.Empty; //TODO: Change this so its a single database hit instead of one per property :( Dictionary <string, int> clicks = Classes.Showcase.ShowcaseItemMetric.GetStatisticsForProperty(obj.ShowcaseItemID, filterList.FilterBeginDate, filterList.FilterEndDate); foreach (KeyValuePair <string, int> kvp in clicks) { dr[kvp.Key + " Clicks"] = kvp.Value; } objects.Rows.Add(dr); } Cache.Store(key, objects); Cache.Store(countKey, m_ItemCount); } return(objects); }
public ClickType(ClickType objectToCopy) { ClickTypeID = objectToCopy.ClickTypeID; Name = objectToCopy.Name; }