예제 #1
0
 public bool Filter(EventSearchOptions searchOption, Event someEvent)
 {
     if (searchOption.EventId != 0)
     {
         if (searchOption.EventId != someEvent.Event1)
         {
             return(false);
         }
     }
     if (searchOption.EventType != 0)
     {
         if (searchOption.EventType != someEvent.EventType)
         {
             return(false);
         }
     }
     if (searchOption.User != 0)
     {
         if (searchOption.User != someEvent.User)
         {
             return(false);
         }
     }
     if (searchOption.MinDate != DateTime.MinValue)
     {
         if (NotInDate(someEvent.Date, searchOption.MinDate, searchOption.MaxDate))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
0
        public List <EventSearchResult> Match(EventSearchOptions options, User client)
        {
            List <EventSearchResult> results = new List <EventSearchResult>();
            int age = client.Age;

            List <Event> events = _repository.Events.GetAll().Where(x => (x.Country == options.Country || options.Country == "All") &&
                                                                    (x.City == options.City || options.City == "Всі")).ToList();

            if (options.Interests == null)
            {
                foreach (var e in events)
                {
                    results.Add(Calculate(client, e));
                }
                return(results);
            }

            foreach (var e in events)
            {
                if (FilterInterests(e, options.Interests))
                {
                    results.Add(Calculate(client, e));
                }
            }

            return(results);
        }
예제 #3
0
        public async Task <ICollection <Event> > Find(EventSearchOptions searchOptions)
        {
            var eventFilter = new EventFilter();

            eventRepository.Find(f => eventFilter.Filter(searchOptions, f));

            var result = await Task.Run(() => eventRepository.PagingInFound(0, 10, x => x.Id));

            return(result.ToList());
        }
예제 #4
0
        public IActionResult GetPotentials(string num, [FromBody] EventSearchOptions options)
        {
            User user = _repository.Users.GetByNumber(num);

            if (user == null)
            {
                return(NotFound());
            }

            var results = _matcher.Match(options, user);

            return(Ok(results));
        }
예제 #5
0
        public async Task <HttpResponseMessage> Search(HttpRequestMessage request, EventSearchOptions value)
        {
            try
            {
                var events = await eventService.Find(value).ConfigureAwait(false);

                var result = Mapper.Map <IEnumerable <Event>, List <EventDTO> >(events);

                return(request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }