public void AddSearchResult(DTO.SearchResultDTO abs) { try { using (var context = new Models.EnterpriseContext()) { var addRecord = new Models.SearchResultDTO { TrackId = abs.TrackId, TrackName = abs.TrackName, ArtistName = abs.ArtistName, Category = abs.Category, UserAgent = abs.UserAgent, UserIP = abs.UserIP, ClickCount = 1, RowCreateTS = DateTime.Now, RowMaintainedTS = DateTime.Now }; context.SearchResultCounters.Add(addRecord); context.SaveChanges(); } } catch (Exception e) { throw e; } }
public DTO.SearchResultDTO GetSearchCount(string TrackId) { try { using (Models.EnterpriseContext db = new Models.EnterpriseContext()) { var searchCount = db.SearchResultCounters .Where(x => x.TrackId == TrackId).ToList(); if (searchCount.Any()) { DTO.SearchResultDTO search = new DTO.SearchResultDTO(); search.Id = searchCount.FirstOrDefault().Id; search.TrackId = searchCount.FirstOrDefault().TrackId; search.TrackName = searchCount.FirstOrDefault().TrackName; search.ArtistName = searchCount.FirstOrDefault().ArtistName; search.Category = searchCount.FirstOrDefault().Category; search.ClickCount = searchCount.FirstOrDefault().ClickCount; search.UserIP = searchCount.FirstOrDefault().UserIP; search.UserAgent = searchCount.FirstOrDefault().UserAgent; search.RowCreateTS = searchCount.FirstOrDefault().RowCreateTS; search.RowMaintainedTS = searchCount.FirstOrDefault().RowMaintainedTS; return(search); } else { return(null); } } } catch (Exception e) { throw e; } }