public void LogSearchQuerryWithParameters(IList <SearchProductAttributeValue> searchAttributes, IList <SearchProductAttributeValue> customerAttributes, int activityLogId, int regionId, int customerId, int categoryId, int productTagId, int bankRating, int productRating) { var searchQuery = new SearchQueryLog() { ActivityLogId = activityLogId, RegionId = regionId, BankRating = bankRating, CategoryId = categoryId, ProductTagId = productTagId, ProductRating = productRating, CustomerId = customerId }; _searchQueryRepository.Insert(searchQuery); LogSearchQuery(searchAttributes, customerAttributes, searchQuery); }
public async Task <List <SearchQueryLog> > GetSearchQueryLogs() { List <SearchQueryLog> refinedLog = new List <SearchQueryLog>(); var result = await _db.SearchQueryLogs.ToListAsync(); var searchSorted = result.GroupBy(item => new { item.SearchQuery, item.PropertyType }, (key, group) => new { key1 = key.SearchQuery, key2 = key.PropertyType, All = group.ToList() }); foreach (var group in searchSorted) { SearchQueryLog searchLog = new SearchQueryLog(); searchLog.SearchQuery = group.key1; searchLog.PropertyType = group.key2; searchLog.CountResultFoundInOtherFirms = 0; searchLog.CountResultFoundInQueriedFirm = 0; foreach (var item in group.All) { searchLog.SearchLocation = item.SearchLocation; searchLog.QueriedFirm = item.QueriedFirm; searchLog.CountResultFoundInQueriedFirm = searchLog.CountResultFoundInQueriedFirm + item.CountResultFoundInQueriedFirm; searchLog.CountResultFoundInOtherFirms = searchLog.CountResultFoundInOtherFirms + item.CountResultFoundInOtherFirms; searchLog.DateQueried = item.DateQueried; } refinedLog.Add(searchLog); } return(refinedLog); }
public void AddSearchQueryToLog(string searchQuery, string searchLocation, int queriedFirmId, PropertyType propertyType, int resultInFirm, int resultInOtherFirms) { var firm = _db.Firms.FirstOrDefault(m => m.Id == queriedFirmId); if (firm == null) { firm = new Firm(); } var searchLog = new SearchQueryLog { SearchQuery = searchQuery, SearchLocation = searchLocation, QueriedFirm = firm.Name, PropertyType = propertyType, CountResultFoundInQueriedFirm = resultInFirm, CountResultFoundInOtherFirms = resultInOtherFirms, DateQueried = DateTime.Now }; SaveSearchQueryToDb(searchLog); }
public void SaveSearchQueryToDb(SearchQueryLog searchQueryLog) { _db.SearchQueryLogs.Add(searchQueryLog); _db.SaveChangesAsync(); }
public void LogSearchQuery(IList <SearchProductAttributeValue> searchAttributes, IList <SearchProductAttributeValue> customerAttributes, SearchQueryLog query) { if (searchAttributes != null) { foreach (var attribute in searchAttributes) { var log = new SearchLog() { CategoryProductAttributeId = attribute.CategoryProductAttributeId, ExactValue = attribute.ExactValue, IdValue = attribute.IdValue, MaxValue = attribute.MaxValue, MinValue = attribute.MinValue, Textvalue = attribute.Textvalue, CustomerAttribute = false }; query.SearchLogs.Add(log); _searchQueryRepository.Update(query); } } if (customerAttributes != null) { foreach (var attribute in customerAttributes) { var log = new SearchLog() { CategoryProductAttributeId = attribute.CategoryProductAttributeId, ExactValue = attribute.ExactValue, IdValue = attribute.IdValue, MaxValue = attribute.MaxValue, MinValue = attribute.MinValue, Textvalue = attribute.Textvalue, CustomerAttribute = true }; query.SearchLogs.Add(log); _searchQueryRepository.Update(query); } } }