public IEnumerable <ISearchStrategy <object, Event> > Create(SearchParamsDTO searchParams)
        {
            var searchStrategies = new List <ISearchStrategy <object, Event> >();

            if (searchParams.From != null && searchParams.From.HasValue && searchParams.To != null && searchParams.To.HasValue)
            {
                var param = new FromToParam(searchParams.From.Value, searchParams.To.Value);
                searchStrategies.Add(new DateSearchStrategy(param));
            }
            else if (searchParams.From != null && searchParams.From.HasValue)
            {
                var param = new FromToParam(searchParams.From.Value, DateTime.MaxValue);
                searchStrategies.Add(new DateSearchStrategy(param));
            }
            else if (searchParams.To != null && searchParams.To.HasValue)
            {
                var param = new FromToParam(DateTime.MinValue, searchParams.To.Value);
                searchStrategies.Add(new DateSearchStrategy(param));
            }
            else if (searchParams.Data != null && !string.IsNullOrEmpty(searchParams.Data))
            {
                searchStrategies.Add(new DataSearchStrategy(searchParams.Data));
            }

            return(searchStrategies);
        }
        public IEnumerable <Event> EventsSearch(SearchParamsDTO searchParams)
        {
            var domainEvents               = new List <Event>();
            var searchStrategies           = _searchStrategyFactory.Create(searchParams);
            var eventStoreConnectionString = GetConnectionString(searchParams.ConnectionId);

            var eventStoreEvent = _eventStoreSearchRepositopy.SearchInAllEventsAsync(eventStoreConnectionString).Result;

            foreach (var @event in eventStoreEvent)
            {
                var eventData   = System.Text.Encoding.UTF8.GetString(@event.Event.Data);
                var domainEvent = new Event(@event.Event.EventStreamId, @event.Event.EventNumber, @event.Event.Created, eventData, @event.Event.EventType);
                domainEvents.Add(domainEvent);
            }

            return(domainEvents);
        }
        public async Task <ActionResult <IEnumerable <Product> > > GetProducts([FromBody] SearchParamsDTO param)
        {
            List <Product> products = new List <Product>();

            products.Add(
                new Product()
            {
                Shop      = param.Shop,
                ItemGroup = param.ItemGroup,
                Name      = param.Name,
                PriceUnit = param.PriceUnit,
                Price     = param.Price
            }
                );

            return(products);
            //return await _context.Products.ToListAsync();
        }
        public IEnumerable <Event> StreamSearch(string stream, SearchParamsDTO searchParams)
        {
            var domainEvents               = new List <Event>();
            var searchStrategies           = _searchStrategyFactory.Create(searchParams);
            var eventStoreConnectionString = GetConnectionString(searchParams.ConnectionId);

            var eventStoreEvent = _eventStoreSearchRepositopy.SearchInStreamAsync(stream, eventStoreConnectionString).Result;


            foreach (var @event in eventStoreEvent)
            {
                var isAvaible   = true;
                var eventData   = System.Text.Encoding.UTF8.GetString(@event.Event.Data);
                var domainEvent = new Event(@event.Event.EventStreamId, @event.Event.EventNumber, @event.Event.Created, eventData, @event.Event.EventType);

                if (searchStrategies == null || searchStrategies.Count() == 0)
                {
                    domainEvents.Add(domainEvent);
                }
                else
                {
                    foreach (var searchStrategy in searchStrategies)
                    {
                        if (!searchStrategy.Compare(domainEvent))
                        {
                            isAvaible = false;
                            break;
                        }
                    }

                    if (isAvaible)
                    {
                        domainEvents.Add(domainEvent);
                    }
                }
            }

            return(domainEvents);
        }
        public IEnumerable <Event> StreamSearchByEventNumber(string stream, long eventNumber, SearchParamsDTO searchParams)
        {
            var eventStoreConnectionString = GetConnectionString(searchParams.ConnectionId);
            var searchTask = _eventStoreSearchRepositopy.SearchByEventNumberAsync(stream, eventNumber, eventStoreConnectionString);

            searchTask.Wait();
            var eventStoreEvent = searchTask.Result;

            var domainEvents = new List <Event>();

            if (eventStoreEvent != null && eventStoreEvent.Event.HasValue)
            {
                var eventData = System.Text.Encoding.UTF8.GetString(eventStoreEvent.Event.Value.Event.Data);
                var @event    = new Event(eventStoreEvent.Stream, eventStoreEvent.EventNumber, eventStoreEvent.Event.Value.Event.Created, eventData, eventStoreEvent.Event.Value.Event.EventType);
                domainEvents.Add(@event);
            }

            return(domainEvents);
        }
        public IEnumerable <Event> AllEventsSearch(SearchParamsDTO searchParams)
        {
            var test = this.User.Claims.Where(c => c.Type == ClaimsIdentity.DefaultNameClaimType);

            return(_searchService.EventsSearch(searchParams));
        }
 public IEnumerable <Event> StreamSearch(string stream, long eventNumber, SearchParamsDTO searchParams)
 {
     return(_searchService.StreamSearchByEventNumber(stream, eventNumber, searchParams));
 }
 public IEnumerable <Event> StreamSearch(string stream, SearchParamsDTO searchParams)
 {
     return(_searchService.StreamSearch(stream, searchParams));
 }