public ActionResult Index() { var result = _providerRepository.GetAllProviders(); var allProviders = _mapper.Map <List <ProviderViewModel> >(result); var searches = _searchRepository.GetAll(); var statistics = searches.Aggregate(new Statistics(), (acc, search) => acc.Accumulate(search), acc => acc.Compute()); ViewBag.Statistics = statistics; ViewBag.MaxDuration = statistics.DurationCounts.Max(); return(View(allProviders)); }
/// <summary> /// Performs search in repository /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="query">BoostedSearchQuery object containing query information</param> /// <returns></returns> public IEnumerable <TEntity> Search <TEntity>(BoostedSearchQuery query) where TEntity : class { CheckQuery(query); var similarQueries = this.GetSimilarQueries(query.Query); var coincidentQuery = similarQueries.FirstOrDefault(t => t.QueryString.Equals(query.Query, StringComparison.InvariantCultureIgnoreCase)); if (coincidentQuery == null) { UserQuery userQuery = new UserQuery(); userQuery.QueryString = query.Query; _repository.Insert(userQuery); } return(_repository.GetAll <TEntity>(query.Query, query.SearchableFields, query.BoostValues, MaxResultCount)); }
public void Get_GetAllOneWordQuery_Return_EqualCount_Not_Zero() { sut = new LuceneSearchRepository(true); foreach (var product in products) { sut.Insert <TestProduct>(product); } var result = sut.GetAll <TestProduct>("product", new string[] { "Name", "Composition" }, 1000); Assert.AreEqual(5, result.Count()); result = sut.GetAll <TestProduct>("product1", new string[] { "Name", "Composition" }, 1000); Assert.AreEqual(1, result.Count()); }
public void GetAll_GetAll_Return_NoException() { sut = new LuceneSearchRepository(true); foreach (var user in users) { sut.Insert(user); } var userCollectionFromRepo = sut.GetAll <TestUser>(); }
public void GetAllParams_EmptyFields_Return_ArgumentException() { sut = new LuceneSearchRepository(true); foreach (var user in users) { sut.Insert(user); } var queryList = new List <string>(); Assert.Throws <ArgumentException>(() => sut.GetAll <TestUser>("user", queryList, 1000)); }
public void Get_GetAllMultiplyWordQuery_WrongField_Return_EqualCount_Not_Zero() { sut = new LuceneSearchRepository(true); foreach (var product in products) { sut.Insert <TestProduct>(product); } var result = sut.GetAll <TestProduct>("product", new string[] { "NonExistentField" }, 1000); Assert.AreEqual(0, result.Count()); }
public void GetAll_GetAll_Return_EqualCount() { sut = new LuceneSearchRepository(true); foreach (var user in users) { sut.Insert(user); } var userCollectionFromRepo = sut.GetAll <TestUser>(); Assert.AreEqual(users.Count(), userCollectionFromRepo.Count()); }
public void GetAllParams_EmptyQuery_Return_ArgumentException() { sut = new LuceneSearchRepository(true); foreach (var user in users) { sut.Insert(user); } var queryList = new List <string>(); queryList.Add("Login"); queryList.Add("Email"); Assert.Throws <ArgumentException>(() => sut.GetAll <TestUser>(String.Empty, queryList, 1000)); }
public void GetAllParams_SearchUpperCase_Return_EqualCount_1() { sut = new LuceneSearchRepository(true); foreach (var user in users) { sut.Insert(user); } var queryList = new List <string>(); queryList.Add("Login"); var userCollectionFromRepo = sut.GetAll <TestUser>("user5", queryList, 1000); Assert.AreEqual(1, userCollectionFromRepo.Count()); }
public void Get_GetAllMultiplyWordQuery_Return_EqualCount_Not_Zero() { sut = new LuceneSearchRepository(true); foreach (var product in products) { sut.Insert <TestProduct>(product); } var result = sut.GetAll <TestProduct>("name1 word1 word2 word3", new string[] { "Name", "Composition" }, 1000); Assert.AreEqual(1, result.Count()); result = sut.GetAll <TestProduct>("word1 word2 NamE1 word3", new string[] { "Name", "Composition" }, 1000); Assert.AreEqual(1, result.Count()); result = sut.GetAll <TestProduct>("word1 composition1", new string[] { "Name", "Composition" }, 1000); Assert.AreEqual(1, result.Count()); result = sut.GetAll <TestProduct>("name1 composition2", new string[] { "Name", "Composition" }, 1000); Assert.AreEqual(2, result.Count()); result = sut.GetAll <TestProduct>("Word1 Word2 NamE1 CompositioN1 NamE2 ProducT2 Word3 Word4", new string[] { "Composition" }, 1000); Assert.AreEqual(2, result.Count()); }
public void Get_GetAllMultiplyWordQuery_With_Boost_Return_EqualCount_Not_Zero() { sut = new LuceneSearchRepository(true); foreach (var product in products) { sut.Insert <TestProduct>(product); } var boostValues = new Dictionary <string, float>(); boostValues.Add("Name", 1.0f); boostValues.Add("Composition", 1.0f); var result = sut.GetAll <TestProduct>("product", new string[] { "Name", "Composition" }, new ReadOnlyDictionary <string, float>(boostValues), 1000); Assert.AreEqual(5, result.Count()); }
public bool Subscribe(SubscribeViewModel subscribeViewModel) { Throw.IfNull(subscribeViewModel, nameof(subscribeViewModel)); Throw.IfNull(subscribeViewModel.Email, nameof(subscribeViewModel.Email)); List <string> tags; if (Context.User.Profile.Email == subscribeViewModel.Email) { var propertyValue = Context.User.Profile.GetCustomProperty(Tags); tags = string.IsNullOrWhiteSpace(propertyValue) ? new List <string>() : Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(propertyValue); } else { tags = _tagsRepository.GetAll(EventTag.TemplateId).Select(i => i.TagName).ToList(); } var subscriber = _subscribersRepository .Get(i => i.Email == subscribeViewModel.Email); if (subscriber == null) { _subscribersRepository.Create(new Subscriber { Email = subscribeViewModel.Email, Tags = tags }); _logger.Info($"Created new subscriber {subscribeViewModel.Email}"); } else { if (!subscriber.IsSubscribed) { _subscribersRepository.UpdateField(subscriber.Id, i => i.IsSubscribed, true); _logger.Info($"User {subscribeViewModel.Email} subscribed again"); } _subscribersRepository.UpdateField(subscriber.Id, i => i.Tags, tags); } return(true); }
private List <IEventDetailsPage> GetEventsToSend(Subscriber subscriber) { var userTagIds = _tagsRepository .GetAll(EventTag.TemplateId, i => subscriber.Tags.Contains(i.TagName)) .Select(i => i.Id) .ToList(); var eventsForSubscriber = _eventRepository.GetAll(EventDetailsPage.TemplateId) .Where(i => i.Tags != null && i.Tags.Any(x => userTagIds.Contains(x.Id))) .ToList(); var lastSentEmail = _emailsRepository.GetAll( i => i.Recipient == subscriber.Email, o => o.DateAdded).ToList().LastOrDefault(); if (lastSentEmail != null) { var eventsToSend = eventsForSubscriber .Where(i => !lastSentEmail.EventIds.Contains(i.Id.ToString("N"))) .ToList(); if (eventsToSend.Any()) { return(eventsToSend.Take(MailingConstants.CountEventsToEmail).ToList()); } } else { if (eventsForSubscriber.Any()) { return(eventsForSubscriber.Take(MailingConstants.CountEventsToEmail).ToList()); } } return(null); }
private List <IEventTag> GetUnselectedList(List <IEventTag> selectedTags) { var allTags = _tagRepository.GetAll(EventTag.TemplateId); return(allTags.Where(i => selectedTags.All(tag => tag.TagName != i.TagName)).ToList()); }
public ICollection <BusinessSearchResultsDto> SearchByCompanyName(string comapnyName) { return(_mapper.Map <IList <BusinessSearchResultsDto> >(_repository.GetAll(comapnyName))); }
public IEnumerable <Search> Get() { return(_searchRepository.GetAll().ToList()); }
public IEnumerable <Search> GetAllProducts() { return(repository.GetAll()); }