Esempio n. 1
0
        private static async Task <IEnumerable <EventDto> > Match16Async(EventQueryModel queryModel)
        {
            var cityId = int.Parse(queryModel.CityId);
            var date   = DateTime.Parse(queryModel.Date);

            return(await FindAllAsync(e => e.CityId == cityId && e.EventDate == date, queryModel.Page, queryModel.PageSize));
        }
Esempio n. 2
0
        public async Task <List <Calendar> > GetCalendar(EventQueryModel query)
        {
            IQueryable <Calendar> calendars = _context.Calendar;

            if (query.Location != null)
            {
                calendars = calendars.Where(o => o.Location == query.Location);
            }

            if (query.EventOrganizer != null)
            {
                calendars = calendars.Where(o => o.EventOrganizer == query.EventOrganizer);
            }

            if (query.Name != null)
            {
                calendars = calendars.Where(o => o.Name == query.Name);
            }

            if (query.Id > 0)
            {
                calendars = calendars.Where(o => o.Id == query.Id);
            }
            return(await calendars.OrderBy(o => o.Id).ToListAsync());
        }
Esempio n. 3
0
        private static async Task <long> Match20Async(EventQueryModel queryModel)
        {
            var dateFrom = DateTime.Parse(queryModel.DateFrom);
            var dateTo   = DateTime.Parse(queryModel.DateTo);

            return(await CountAll(e => e.City.CityName.ToUpper().Contains(queryModel.CityName.ToUpper()) && e.EventDate >= dateFrom && e.EventDate <= dateTo));
        }
Esempio n. 4
0
        private static async Task <long> Match31Async(EventQueryModel queryModel)
        {
            var date = DateTime.Parse(queryModel.Date);

            return(await CountAll(e => e.City.CityName.ToUpper().Contains(queryModel.CityName.ToUpper()) && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) &&
                                  e.EventDate == date));
        }
Esempio n. 5
0
        private static async Task <long> Match26Async(EventQueryModel queryModel)
        {
            var dateTo = DateTime.Parse(queryModel.DateTo);

            return(await CountAll(e => e.City.CityName.ToUpper().Contains(queryModel.CityName.ToUpper()) && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) &&
                                  e.Categories.Any(x => x.CategoryName.ToUpper().Contains(queryModel.CategoryName.ToUpper())) && e.EventDate <= dateTo));
        }
Esempio n. 6
0
        private static async Task <long> Match16Async(EventQueryModel queryModel)
        {
            var cityId = int.Parse(queryModel.CityId);
            var date   = DateTime.Parse(queryModel.Date);

            return(await CountAll(e => e.CityId == cityId && e.EventDate == date));
        }
Esempio n. 7
0
        private static async Task <long> Match41Async(EventQueryModel queryModel)
        {
            var catId = int.Parse(queryModel.CategoryId);
            var date  = DateTime.Parse(queryModel.Date);

            return(await CountAll(e => e.Categories.Any(x => x.Id == catId) && e.EventDate == date));
        }
Esempio n. 8
0
        private static async Task <IEnumerable <EventDto> > Match27Async(EventQueryModel queryModel)
        {
            var dateTo = DateTime.Parse(queryModel.DateTo);

            return(await FindAllAsync(e => e.City.CityName.ToUpper().Contains(queryModel.CityName.ToUpper()) && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) &&
                                      e.EventDate <= dateTo, queryModel.Page, queryModel.PageSize));
        }
Esempio n. 9
0
        private static async Task <IEnumerable <EventDto> > Match46Async(EventQueryModel queryModel)
        {
            var dateFrom = DateTime.Parse(queryModel.DateFrom);
            var dateTo   = DateTime.Parse(queryModel.DateTo);

            return(await FindAllAsync(e => e.EventDate >= dateFrom && e.EventDate <= dateTo, queryModel.Page, queryModel.PageSize));
        }
Esempio n. 10
0
        private static async Task <long> Match46Async(EventQueryModel queryModel)
        {
            var dateFrom = DateTime.Parse(queryModel.DateFrom);
            var dateTo   = DateTime.Parse(queryModel.DateTo);

            return(await CountAll(e => e.EventDate >= dateFrom && e.EventDate <= dateTo));
        }
Esempio n. 11
0
        private static async Task <IEnumerable <EventDto> > Match41Async(EventQueryModel queryModel)
        {
            var catId = int.Parse(queryModel.CategoryId);
            var date  = DateTime.Parse(queryModel.Date);

            return(await FindAllAsync(e => e.Categories.Any(x => x.Id == catId) && e.EventDate == date, queryModel.Page, queryModel.PageSize));
        }
Esempio n. 12
0
        private static async Task <IEnumerable <EventDto> > Match45Async(EventQueryModel queryModel)
        {
            var date = DateTime.Parse(queryModel.Date);

            return(await FindAllAsync(e => e.Categories.Any(x => x.CategoryName.ToUpper().Contains(queryModel.CategoryName.ToUpper())) && e.EventDate == date,
                                      queryModel.Page, queryModel.PageSize));
        }
Esempio n. 13
0
        private static async Task <IEnumerable <EventDto> > Match34Async(EventQueryModel queryModel)
        {
            var cityId = int.Parse(queryModel.CityId);

            return(await FindAllAsync(e => e.CityId == cityId && e.Categories.Any(x => x.CategoryName.ToUpper().Contains(queryModel.CategoryName.ToUpper())),
                                      queryModel.Page, queryModel.PageSize));
        }
Esempio n. 14
0
        private static async Task <IEnumerable <EventDto> > Match33Async(EventQueryModel queryModel)
        {
            var cityId = int.Parse(queryModel.CityId);
            var catId  = int.Parse(queryModel.CategoryId);

            return(await FindAllAsync(e => e.CityId == cityId && e.Categories.Any(x => x.Id == catId), queryModel.Page, queryModel.PageSize));
        }
Esempio n. 15
0
        private static async Task <long> Match33Async(EventQueryModel queryModel)
        {
            var cityId = int.Parse(queryModel.CityId);
            var catId  = int.Parse(queryModel.CategoryId);

            return(await CountAll(e => e.CityId == cityId && e.Categories.Any(x => x.Id == catId)));
        }
Esempio n. 16
0
        private static async Task <long> Match11Async(EventQueryModel queryModel)
        {
            var cityId = int.Parse(queryModel.CityId);
            var dateTo = DateTime.Parse(queryModel.DateTo);

            return(await CountAll(e => e.CityId == cityId && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) && e.EventDate <= dateTo));
        }
Esempio n. 17
0
        private static async Task <long> Match29Async(EventQueryModel queryModel)
        {
            var catId = int.Parse(queryModel.CategoryId);
            var date  = DateTime.Parse(queryModel.Date);

            return(await CountAll(e => e.City.CityName.ToUpper().Contains(queryModel.CityName.ToUpper()) && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) &&
                                  e.Categories.Any(x => x.Id == catId) && e.EventDate == date));
        }
Esempio n. 18
0
        private static async Task <IEnumerable <EventDto> > Match7Async(EventQueryModel queryModel)
        {
            var cityId   = int.Parse(queryModel.CityId);
            var dateFrom = DateTime.Parse(queryModel.DateFrom);

            return(await FindAllAsync(e => e.CityId == cityId && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) && e.EventDate >= dateFrom,
                                      queryModel.Page, queryModel.PageSize));
        }
Esempio n. 19
0
        private static async Task <IEnumerable <EventDto> > Match29Async(EventQueryModel queryModel)
        {
            var catId = int.Parse(queryModel.CategoryId);
            var date  = DateTime.Parse(queryModel.Date);//.ToString("yyyy-M-d dddd");

            return(await FindAllAsync(e => e.City.CityName.ToUpper().Contains(queryModel.CityName.ToUpper()) && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) &&
                                      e.Categories.Any(x => x.Id == catId) && e.EventDate == date, queryModel.Page, queryModel.PageSize));
        }
Esempio n. 20
0
        public async Task <PagedItems <EventDto> > GetEventsByParamAsync(EventQueryModel queryModel)
        {
            var events = await _patternMatching.PatternMatchingQueryStringEventAsync(queryModel);

            var eventsCount = await _patternMatchingCount.PatternMatchingQueryStringEventCount(queryModel);

            return(CreatePagedItems(events, eventsCount, queryModel));
        }
Esempio n. 21
0
        public async Task <ActionResult> Get(int id)
        {
            EventQueryModel eventQueryModel = new EventQueryModel();

            eventQueryModel.Id = id;
            List <Calendar> calendars = await repository.GetCalendar(eventQueryModel);

            return(StatusCode(200, calendars.ToArray()));
        }
Esempio n. 22
0
        private static async Task <IEnumerable <EventDto> > Match17Async(EventQueryModel queryModel)
        {
            var catId    = int.Parse(queryModel.CategoryId);
            var dateFrom = DateTime.Parse(queryModel.DateFrom);
            var dateTo   = DateTime.Parse(queryModel.DateTo);

            return(await FindAllAsync(e => e.City.CityName.ToUpper().Contains(queryModel.CityName.ToUpper()) && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) &&
                                      e.Categories.Any(x => x.Id == catId) && e.EventDate >= dateFrom && e.EventDate <= dateTo, queryModel.Page, queryModel.PageSize));
        }
Esempio n. 23
0
        private static async Task <long> Match6Async(EventQueryModel queryModel)
        {
            var cityId   = int.Parse(queryModel.CityId);
            var dateFrom = DateTime.Parse(queryModel.DateFrom);

            return(await CountAll(e => e.CityId == cityId && e.EventName.ToUpper().Contains(queryModel.EventName.ToUpper()) &&
                                  e.Categories.Any(x => x.CategoryName.ToUpper().Contains(queryModel.CategoryName.ToUpper())) &&
                                  e.EventDate >= dateFrom));
        }
Esempio n. 24
0
        public async Task <ActionResult> Get(string location)
        {
            EventQueryModel eventQueryModel = new EventQueryModel();

            eventQueryModel.Location = location;
            var calendars = await repository.GetCalendar(eventQueryModel);

            return(StatusCode(200, calendars.ToArray()));
        }
Esempio n. 25
0
        private static async Task <long> Match1Async(EventQueryModel queryModel)
        {
            var cityId   = int.Parse(queryModel.CityId);
            var catId    = int.Parse(queryModel.CategoryId);
            var dateFrom = DateTime.Parse(queryModel.DateFrom);
            var dateTo   = DateTime.Parse(queryModel.DateTo);

            return(await CountAll(e => e.CityId == cityId && e.EventName.ToUpper().Equals(queryModel.EventName.ToUpper()) && e.Categories.Any(x => x.Id == catId) &&
                                  e.EventDate >= dateFrom && e.EventDate <= dateTo));
        }
Esempio n. 26
0
        public async Task <long> PatternMatchingQueryStringEventCount(EventQueryModel queryModel)
        {
            var  match = PatternMatchQueryStringEventCount.FirstOrDefault(d => d.CheckPatternQueryStringEvent(queryModel));
            long eventsCount;

            if (match != null)
            {
                eventsCount = await match.UseMatchQueryStringEventCount(queryModel);
            }
            else
            {
                eventsCount = await _unitOfWork.EventRepository.Count();
            }

            return(eventsCount);
        }
Esempio n. 27
0
        public async Task <List <EventModel> > GetListAsync(EventQueryModel query)
        {
            var list = new List <EventModel>(query.Limit);

            using (var db = PostgreSqlDbContext.Create(this.options))
            {
                StringBuilder sql = new StringBuilder($"COPY (SELECT typecode,data,datatype,version FROM {tableName} WHERE version > '{query.StartVersion}'");
                if (query.StateId != null)
                {
                    sql.Append($" and stateid = '{query.StateId}'");
                }
                if (query.StartVersion > 0)
                {
                    sql.Append($" and version <= '{query.EndVersion}'");
                }
                if (!string.IsNullOrEmpty(query.EventTypeCode))
                {
                    sql.Append($" and typecode = '{query.EventTypeCode}'");
                }
                if (!string.IsNullOrEmpty(query.RelationEvent))
                {
                    sql.Append($" and relationevent = '{query.RelationEvent}'");
                }
                sql.Append(" ORDER BY version ASC) TO STDOUT(FORMAT BINARY)");

                await db.OpenAsync();

                using (var reader = db.BeginBinaryExport(sql.ToString()))
                {
                    while (reader.StartRow() != -1)
                    {
                        string typeCode  = reader.Read <string>(NpgsqlDbType.Varchar);
                        byte[] dataBytes = reader.Read <byte[]>(NpgsqlDbType.Bytea);
                        string dataType  = reader.Read <string>(NpgsqlDbType.Varchar);
                        long   version   = reader.Read <Int64>(NpgsqlDbType.Bigint);

                        //Get event type
                        EventModel eventModel = this.ConversionEvent(typeCode, dataType, dataBytes, version);
                        if (eventModel != null)
                        {
                            list.Add(eventModel);
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 28
0
        private void Then_GetList_Success(List <EventStorageBufferWrap> list)
        {
            EventQueryModel model = new EventQueryModel()
            {
                StateId = 4000
            };
            var datas = this.storage.GetListAsync(model).GetAwaiter().GetResult();

            Assert.True(datas.Count > 0);


            model = new EventQueryModel()
            {
                RelationEvent = "ABC"
            };
            datas = this.storage.GetListAsync(model).GetAwaiter().GetResult();
            Assert.True(datas.Count > 0);
        }
Esempio n. 29
0
        public async new Task <IList <IEvent <TStateKey> > > GetListAsync(EventQueryModel queryModel)
        {
            queryModel.StateId = this.StateId.ToString();
            List <string> tables = await this._storageFactory.GetTableList(this.Options.EventSourceName, StorageType.EventSource, this.StateId.ToString(), queryModel.StartTime);

            List <IEvent <TStateKey> > events = new List <IEvent <TStateKey> >();

            foreach (var t in tables)
            {
                var eventModels = await _eventStorage.GetListAsync(t, queryModel);

                var _events = this.ConvertEvent <TStateKey>(eventModels);
                events.AddRange(_events);
                if (queryModel.Limit > 0)
                {
                    if (events.Count >= queryModel.Limit)
                    {
                        break;
                    }
                }
            }
            return(events);
        }
Esempio n. 30
0
 public Task <IEnumerable <EventDto> > UseMatchQueryStringEventAsync(EventQueryModel queryModel) => _matchQueryStringEventAsync(queryModel);