private static void Main(string[] args)
        {
            try
            {
                ServiceProvider serviceProvider = InitDepencyInjection();
                System.Console.WriteLine($"Event Search Application Version: 1.0.0.0");

                EventSearchRequest searchRequest = ReadArgs();

                System.Console.WriteLine($"Process started at {DateTime.Now}");

                var dataService = serviceProvider.GetService <IDataService>();

                var response = dataService.ExtractData(searchRequest);

                System.Console.WriteLine(response);
                System.Console.WriteLine($"Process completed at {DateTime.Now}");
                System.Console.WriteLine("\npress any key to exit the process...");
                System.Console.ReadKey();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
        private EventSearchRequest GetSearchRequest()
        {
            EventSearchRequest searchRequest = new EventSearchRequest();

            searchRequest           = ApplyDefaultSearchValues(searchRequest) as EventSearchRequest;
            searchRequest.PageIndex = pagination.PageIndex;
            searchRequest.Title     = txtSearchBar.Text;
            searchRequest.Author    = txtAuthor.Text;
            searchRequest.Promoter  = txtPromoter.Text;

            if (!_dateFilterCleared)
            {
                searchRequest.DateAndTime = dtpEventDate.Value.ToUniversalTime();
            }
            else
            {
                searchRequest.DateAndTime = null;
            }

            if (cmbType.SelectedValue != null && int.TryParse(cmbType.SelectedValue.ToString(), out int typeId))
            {
                searchRequest.TypeId = typeId;
            }

            AddIncludes(ref searchRequest);

            return(searchRequest);
        }
Exemple #3
0
        public IEnumerable <LineFeed> Process(EventSearchRequest eventSearchRequest)
        {
            _validationService.Validate(eventSearchRequest);

            if (!File.Exists(eventSearchRequest.FilePath))
            {
                throw new FileNotFoundException($"{eventSearchRequest.FilePath} not found");
            }

            var feeds = new ConcurrentBag <LineFeed>();

            Parallel.ForEach(
                File.ReadLines(eventSearchRequest.FilePath),
                new ParallelOptions {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            },
                (line, state, index) =>
            {
                var entity = _recordService.ExtractLineFeed(line, eventSearchRequest.FeedSeparator, eventSearchRequest.StartDate, eventSearchRequest.EndDate);
                if (entity != null)
                {
                    feeds.Add(entity);
                }
            }
                );
            return(feeds);
        }
        public EventsResponse GetEvents(EventSearchRequest searchRequest)
        {
            var validator = new EventSearchVallidator().Validate(searchRequest).ToResponse();

            if (!validator.Result)
            {
                return new EventsResponse {
                           Result = false, Errors = validator.Errors
                }
            }
            ;

            var response = new EventsResponse();

            try
            {
                response = _eventsRepository.GetEvents(searchRequest);
            }
            catch (Exception ex)
            {
                _logger.Error(ExceptionMessages.GetEventsException, ex);
                response.Result = false;
                response.Errors.Add(new ResponseError {
                    Name = "GetEventsException", Error = ExceptionMessages.GetEventsException
                });
                return(response);
            }

            return(response);
        }
Exemple #5
0
        public IActionResult GetEvents(string name, string city, string category, string location, int offset, int limit = 10)
        {
            var searchRequest = new EventSearchRequest()
            {
                Name     = name,
                City     = city,
                Category = category,
                Location = location,
                Limit    = limit,
                Offset   = offset
            };

            _logger.Information(searchRequest.ToString());
            var response = _eventsService.GetEvents(searchRequest);

            if (!response.Result)
            {
                return(BadRequest(response.Errors));
            }

            if (response.Events.Count == 0)
            {
                return(NotFound(searchRequest));
            }

            return(Ok(response.Events));
        }
Exemple #6
0
        public async Task <IPagedList <EventDto> > GetPagedAsync(EventSearchRequest search)
        {
            var list = await _eventRepo.GetPagedAsync(search, search.Title, search.Author, search.Promoter, search.TypeId, search.DateAndTime);

            var dtoList = PagedList <EventDto> .Map <Event>(_mapper, list);

            return(dtoList);
        }
        private async Task LoadEvents(EventSearchRequest searchRequest)
        {
            var result = await _eventsApi.Get <PagedList <EventDto> >(searchRequest);

            grdList.AutoGenerateColumns = false;
            grdList.DataSource          = result.Data;
            pagination.PageIndex        = result.PageIndex;
            pagination.TotalPages       = result.TotalPages;
        }
        public async Task SearchEvents_FromStubHub_ReturnsArray()
        {
            EventSearchRequest req = new EventSearchRequest();

            req.Q = "Tulsa";
            var res = await this._stubhubService.SearchEvents(req);

            Assert.IsNotNull(res);
        }
Exemple #9
0
        public string ExtractData(EventSearchRequest eventSearchRequest)
        {
            var lineFeeds = _fileService.Process(eventSearchRequest);

            if (lineFeeds != null && lineFeeds.Any())
            {
                return(JsonConvert.SerializeObject(lineFeeds.OrderBy(x => x.EventTime), _jsonSerializerSettings));
            }
            return(string.Empty);
        }
Exemple #10
0
        public async Task <IEnumerable <EventViewModel> > Search(EventSearchRequest request)
        {
            var json = JsonConvert.SerializeObject(request);

            _logger.LogInformation($"search.event ${json}");
            var data = (await _service.SearchAsync(request)).ToList();

            _logger.LogInformation($"found.event {data.Count}");
            return(data);
        }
        public void FileService_EventSearchRequest_FileNoFound()
        {
            var request = new EventSearchRequest
            {
                FilePath      = @"C:\FilnotFoumnd",
                StartDate     = DateTime.Now,
                EndDate       = DateTime.Now,
                FeedSeparator = ' '
            };
            Action act = () => _fileService.Process(request);

            act.Should().Throw <FileNotFoundException>();
        }
        private async void grdList_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            DataGridViewColumn clickedColumn = grdList.Columns[e.ColumnIndex];

            ChangeSorting(clickedColumn.Name);

            EventSearchRequest searchRequest = GetSearchRequest();

            searchRequest.SortColumn = CurrentSortPropertyName;
            searchRequest.SortOrder  = CurrentSortOrder;

            await LoadEvents(searchRequest);
        }
        public async Task <EventSearch> SearchEvents(EventSearchRequest request, int page = 1)
        {
            var row = 50 * page;

            var query = QueryHandler.BuildQuery(request);
            var req   = await this._client.GetAsync($"https://api.stubhub.com/search/catalog/events/v3{query}&rows=10&start={row}");

            var res = await req.Content.ReadAsStringAsync();

            EventSearch jResponse = JsonConvert.DeserializeObject <EventSearch>(res);

            return(jResponse);
        }
        private async void FormEventsList_Load(object sender, EventArgs e)
        {
            this.grdList.DoubleBuffered(true);
            EventSearchRequest searchRequest = new EventSearchRequest();

            AddIncludes(ref searchRequest);

            searchRequest = ApplyDefaultSearchValues(searchRequest) as EventSearchRequest;

            _eventTypes = await _eventTypesApi.Get <PagedList <EventTypeDto> >(new BaseSearchRequest());

            await LoadEvents(searchRequest);
        }
        public void FileService_EventSearchRequest_EmptyFileName()
        {
            var fileInfo = CreateTestFile(string.Empty);

            var request = new EventSearchRequest
            {
                FilePath  = string.Empty,
                StartDate = DateTime.Now,
                EndDate   = DateTime.Now,
            };
            Action act = () => _fileService.Process(request);

            act.Should().Throw <ValidationException>().And.Message.Should().Be("FilePath is empty.");
            fileInfo.Delete();
        }
        public void FileService_EventSearchRequest_Not_Valid_Start_Date()
        {
            var fileInfo = CreateTestFile(string.Empty);

            var request = new EventSearchRequest
            {
                FilePath  = fileInfo.FullName,
                StartDate = DateTime.MinValue,
                EndDate   = DateTime.Now,
            };
            Action act = () => _fileService.Process(request);

            act.Should().Throw <ValidationException>().And.Message.Should().Be("StartDate is not valid.");
            fileInfo.Delete();
        }
        public string getAllEvents(EventSearchRequest request)
        {
            string response;

            try
            {
                MakeCall makeCall = new MakeCall();
                response = makeCall.getAllEventsLoc(request, Globals.eventdetails.FromEvent);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return(response);
        }
Exemple #18
0
        public HttpResponseMessage GetEventListVenue(EventSearchRequest request)
        {
            string response = "";

            try
            {
                VenueDetails venueDetails = new VenueDetails();
                response = venueDetails.getEventByVenue(request);
            }
            catch (Exception Ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Ex));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemple #19
0
        public HttpResponseMessage GetAllEventsLocation(EventSearchRequest request)
        {
            string response = "";

            try
            {
                EventDetails eventDetails = new EventDetails();
                response = eventDetails.getAllEvents(request);
            }
            catch (Exception Ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Ex));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemple #20
0
        private async Task <List <Model.Event> > isEventDateUnique(DateTime eventDate, DateTime startingTime, DateTime endingTime)
        {
            //Checking if there is allready event on current date and time
            List <Model.Event> list = new List <Model.Event>();

            var search = new EventSearchRequest()
            {
                EventDate         = eventDate,
                EventStartingTime = startingTime,
                EventEndingTime   = endingTime
            };

            list = await apiService.Get <List <Model.Event> >(search);

            return(list);
        }
        private async void frmOrganizatorIzvjestaj_Load(object sender, EventArgs e)
        {
            organizator = await _organizatorService.GetById <Organizator>(OrgId);

            EventSearchRequest request = new EventSearchRequest {
                OrganizatorId = OrgId
            };

            eventi = await _eventiService.Get <List <Event> >(request);

            foreach (var item in eventi)
            {
                eventIzvjestaji.Add(new EventIzvjestaj
                {
                    Naziv             = item.Naziv,
                    DatumOdrzavanja   = item.DatumOdrzavanja.ToShortDateString(),
                    KategorijaNaziv   = item.KategorijaNaziv,
                    Mjesto            = item.ProstorOdrzavanjaGradAdresa,
                    VrijemeOdrzavanja = item.VrijemeOdrzavanja
                });
            }

            foreach (var item in eventi)
            {
                ProdajaTipSearchRequest searchRequest = new ProdajaTipSearchRequest {
                    EventId = item.Id
                };
                var vraceniProdajaTipovi = await _prodajaTipService.Get <List <ProdajaTip> >(searchRequest);

                prodajaTipovi.AddRange(vraceniProdajaTipovi);
            }

            ReportDataSource rdsEvent = new ReportDataSource("DataSet1", eventIzvjestaji);

            this.reportViewer1.LocalReport.DataSources.Add(rdsEvent);

            ReportDataSource rdsPrTipovi = new ReportDataSource("DataSet2", prodajaTipovi);

            this.reportViewer1.LocalReport.DataSources.Add(rdsPrTipovi);

            this.reportViewer1.LocalReport.SetParameters(new ReportParameter("OrganizatorNaziv", organizator.Naziv));
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter("Telefon", organizator.Telefon));
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter("Email", organizator.Email));


            this.reportViewer1.RefreshReport();
        }
Exemple #22
0
        public async Task <PagedResponse <EventResponse> > GetEvents(int ID, EventSearchRequest search, PaginationQuery pagination)
        {
            var query = _context.Events
                        .Where(i => i.OrganizerID == ID)
                        .AsNoTracking()
                        .AsQueryable();


            query = ApplyPagination(query, pagination);

            var list = await query.ToListAsync();

            var listDto       = _mapper.Map <List <EventResponse> >(list);
            var pagedResponse = await GetPagedResponse <EventResponse, Event>(listDto, pagination);

            return(pagedResponse);
        }
        public async Task Init(int id)
        {   //Event
            Event = await _eventService.GetById <Event>(id);

            if (Event == null)
            {
                return;
            }
            EventId      = id;
            Naziv        = Event.Naziv;
            DatumVrijeme = Event.DatumOdrzavanja.ToShortDateString() + " - " + Event.VrijemeOdrzavanja + " h";
            Adresa       = Event.ProstorOdrzavanjaGradAdresa;
            Opis         = Event.Opis;
            Organizator  = Event.OrganizatorNaziv;
            Slika        = Event.Slika;

            LikeSearchRequest request = new LikeSearchRequest {
                EventId = id, KorisnikId = Global.Korisnik.Id
            };
            List <Like> likes = await _likeService.Get <List <Like> >(request);

            if (likes != null && likes.Count == 1)
            {
                Like      = likes[0];
                IsLikean  = true;
                ImgSource = "hearticonfilled.png";
            }

            EventSearchRequest eventSearch = new EventSearchRequest {
                EventId = id, IsPreporuka = true
            };
            var preporuceniEventi = await _eventService.Get <List <Event> >(eventSearch);

            if (preporuceniEventi.Count > 0)
            {
                Visible = true;
            }
            PreporuceniEventiList.Clear();
            foreach (var p in preporuceniEventi)
            {
                PreporuceniEventiList.Add(p);
            }
        }
Exemple #24
0
        public EventsResponse GetEvents(EventSearchRequest searchRequest)
        {
            Expression <Func <string, string, bool> > startsWithExpression = (e, r) => e.ToLower().StartsWith(r.ToLower());
            Expression <Func <string, string, bool> > containsExpression   = (e, r) => e.ToLower().Contains(r.ToLower());
            Func <string, string, bool> startsWith = startsWithExpression.Compile();
            Func <string, string, bool> contains   = containsExpression.Compile();

            using (var db = new EventSourceDbContext(_dbContext))
            {
                var events = db.Events.Select(e => e);

                if (!string.IsNullOrEmpty(searchRequest.Name))
                {
                    events = events.Where(e => startsWith(e.Name, searchRequest.Name));
                }

                if (!string.IsNullOrEmpty(searchRequest.City))
                {
                    events = events.Where(e => contains(e.City, searchRequest.City));
                }

                if (!string.IsNullOrEmpty(searchRequest.Category))
                {
                    events = events.Where(e => contains(e.Category, searchRequest.Category));
                }

                if (!string.IsNullOrEmpty(searchRequest.Location))
                {
                    events = events.Where(e => contains(e.Location, searchRequest.Location));
                }

                return(new EventsResponse()
                {
                    TotalCount = events.Count(),
                    Events = events
                             .OrderBy(e => e.Name)
                             .Skip(searchRequest.Offset)
                             .Take(searchRequest.Limit)
                             .ToList()
                });
            }
        }
        public void DataService_ProcessRequest_Emtpy_Result()
        {
            //arrange

            _fileService.Setup(f => f.Process(It.IsAny <EventSearchRequest>())).Returns(new List <LineFeed> {
            });

            var request = new EventSearchRequest
            {
                FilePath      = @"C:\filepath",
                StartDate     = new DateTime(1990, 01, 01, 0, 0, 0),
                EndDate       = new DateTime(1990, 01, 01, 14, 59, 59),
                FeedSeparator = ' '
            };

            //act
            var result = _dataService.ExtractData(request);

            result.Should().BeEmpty();
        }
        public void FileService_EventSearchRequest_Valid_File_WithMoreLines()
        {
            string eventFeeds = @"1990-01-01T02:29:00Z [email protected] 21728403-8671-429f-99bd-404936312a55
                                1990-01-01T04:26:59Z [email protected] 6ca02e3d-e978-4f2f-b920-a6fd01a275fc
                                1990-01-01T10:44:59Z [email protected] 48b9200c-e81c-4eb3-a044-69b2b484c09d
                                1990-01-01T18:45:32Z [email protected] 25ba55dd-0060-4004-a776-ef5ac6d29b84";

            var fileInfo = CreateTestFile(eventFeeds);
            var request  = new EventSearchRequest
            {
                FilePath      = fileInfo.FullName,
                StartDate     = new DateTime(1990, 01, 01, 0, 0, 0),
                EndDate       = new DateTime(1990, 01, 01, 14, 59, 59),
                FeedSeparator = ' '
            };
            var result = _fileService.Process(request);

            result.Should().NotBeNull();
            result.Should().HaveCount(1);
            fileInfo.Delete();
        }
Exemple #27
0
        public async Task Init(int katId, string pretraga)
        {
            if (katId == 0)
            {
                return;
            }

            request = new EventSearchRequest {
                KategorijaId = katId, Predstojeci = true, PretragaNazivLokacija = pretraga
            };


            var eventi = await _eventService.Get <List <Event> >(request);

            EventiList.Clear();

            foreach (var e in eventi)
            {
                EventiList.Add(e);
            }
        }
Exemple #28
0
        /// <summary>
        /// Returns the Event collection.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public IEnumerable <Event> GetEvents(EventSearchRequest request)
        {
            var events = new List <Event>();

            var response = GetAsync(
                $"events?" +
                $"name={request.Name}&" +
                $"city={request.City}&" +
                $"category={request.Category}&" +
                $"location={request.Location}&" +
                $"limit={request.Limit}&" +
                $"offset={request.Offset}")
                           .Result;

            if (response.IsSuccessStatusCode)
            {
                var result = response.Content.ReadAsStringAsync().Result;
                events = JsonConvert.DeserializeObject <List <Event> >(result);
            }

            return(events);
        }
Exemple #29
0
        public async Task Init()
        {
            EventSearchRequest searchRequest = new EventSearchRequest();

            searchRequest.Includes.Add("Author");
            searchRequest.Includes.Add("Type");

            var events = await _eventsApi.Get <PagedList <EventDto> >(searchRequest, null);

            if (events.Data.Count == 0)
            {
                NoItems = true;
            }
            else
            {
                //after each navigateBack button from the Reservations Details we need to clear the observableCollection since it will contain the existing data and populate it with the new (same) one again.
                Events.Clear();
                foreach (EventDto r in events.Data)
                {
                    Events.Add(r);
                }
            }
        }
Exemple #30
0
        private async Task <IPagedList <Event> > GetEventsAsync(int pageNumber = 1, int pageSize = 3)
        {
            EventSearchRequest request = new EventSearchRequest();

            if (!string.IsNullOrWhiteSpace(txtNazivEventa.Text))
            {
                request.Naziv = txtNazivEventa.Text;
            }
            if (cmbKategorije.SelectedIndex != 0)
            {
                request.KategorijaId = (cmbKategorije.SelectedItem as Kategorija).Id;
            }
            if (cmbGrad.SelectedIndex != 0)
            {
                request.GradId = (cmbGrad.SelectedItem as Grad).Id;
            }
            request.IsOdobren   = ckbOdobreni.Checked;
            request.IsOtkazan   = ckbOtkazani.Checked;
            request.Predstojeci = ckbPredstojeci.Checked;

            var eventi = await _eventiService.Get <List <Event> >(request);

            return(eventi.ToPagedList(pageNumber, pageSize));
        }