예제 #1
0
        public async Task <ApiResult <List <Sport> > > GetAll()
        {
            var stopwatch = Stopwatch.StartNew();
            var apiResult = new ApiResult <List <Sport> >();

            try
            {
                _logger.Information("Get all sports");
                apiResult.Result = await _sportService.GetAll();

                apiResult.Succeed = true;
                _logger.Information("Get all sports complete");
            }
            catch (Exception ex)
            {
                apiResult.Succeed = false;
                apiResult.Result  = null;
                apiResult.Error   = ex.ToString();
                _logger.Error($"Get all sports error: {ex}");
            }
            stopwatch.Stop();
            apiResult.ExecutionTime = stopwatch.Elapsed.TotalMilliseconds;
            _logger.Information($"Execution time: {apiResult.ExecutionTime}ms");
            return(apiResult);
        }
예제 #2
0
        public UIElement GetAddElement()
        {
            UIElement element = null;

            using (ISportService service = factory.CreateSportService())
            {
                DataServiceMessage <IEnumerable <string> > serviceMessage = service.GetAll();
                RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);

                if (serviceMessage.IsSuccessful)
                {
                    IEnumerable <string> sports = serviceMessage.Data;
                    element = Add(sports);
                }
                else
                {
                    List <ServiceMessage> messages = new List <ServiceMessage>()
                    {
                        serviceMessage
                    };

                    ErrorViewModel viewModel = new ErrorViewModel(messages);
                    ErrorControl   control   = new ErrorControl(viewModel);

                    element = control;
                }
            }

            return(element);
        }
예제 #3
0
        public UIElement GetDisplayElement()
        {
            ParticipantListViewModel viewModel = new ParticipantListViewModel(this, facade);
            ParticipantListControl   control   = new ParticipantListControl(viewModel);

            viewModel.ParticipantSelected += (s, e) =>
            {
                DataServiceMessage <IEnumerable <string> > countryServiceMessage;
                DataServiceMessage <IEnumerable <string> > sportServiceMessage;

                using (ICountryService service = factory.CreateCountryService())
                {
                    countryServiceMessage = service.GetAll();
                    RaiseReceivedMessageEvent(countryServiceMessage.IsSuccessful, countryServiceMessage.Message);
                }
                using (ISportService service = factory.CreateSportService())
                {
                    sportServiceMessage = service.GetAll();
                    RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message);
                }

                if (countryServiceMessage.IsSuccessful && sportServiceMessage.IsSuccessful)
                {
                    var countries = countryServiceMessage.Data;
                    var sports    = sportServiceMessage.Data;

                    Edit(e.Participant, countries, sports);
                }
            };
            viewModel.ParticipantDeleteRequest += (s, e) => Delete(e.Participant);

            return(control);
        }
예제 #4
0
        public IHttpActionResult GetAllSports()
        {
            var sports   = sportService.GetAll();
            var sportDto = sports.Select(sportMapper.Map).ToList();

            return(Ok(sportDto));
        }
예제 #5
0
        public UIElement GetAddElement()
        {
            UIElement element = null;

            DataServiceMessage <IEnumerable <string> > sportServiceMessage;
            DataServiceMessage <IEnumerable <TournamentDisplayDTO> >     tournamentServiceMessage;
            DataServiceMessage <IEnumerable <ParticipantTournamentDTO> > participantServiceMessage;

            using (ITournamentService service = factory.CreateTournamentService())
            {
                tournamentServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(tournamentServiceMessage.IsSuccessful, tournamentServiceMessage.Message);
            }
            using (ISportService service = factory.CreateSportService())
            {
                sportServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message);
            }
            using (IParticipantService service = factory.CreateParticipantService())
            {
                participantServiceMessage = service.GetAllWithTournaments();
                RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message);
            }

            if (tournamentServiceMessage.IsSuccessful && sportServiceMessage.IsSuccessful && participantServiceMessage.IsSuccessful)
            {
                IEnumerable <string> sports = sportServiceMessage.Data;
                IEnumerable <TournamentDisplayDTO>     tournamentDisplayDTOs     = tournamentServiceMessage.Data;
                IEnumerable <ParticipantTournamentDTO> participantTournamentDTOs = participantServiceMessage.Data;

                IEnumerable <TournamentBaseModel> tournamentBaseModels = tournamentDisplayDTOs
                                                                         .Select(t => Mapper.Map <TournamentDisplayDTO, TournamentBaseModel>(t))
                                                                         .ToList();
                IEnumerable <ParticipantTournamentModel> participantTournamentModels = participantTournamentDTOs
                                                                                       .Select(p => Mapper.Map <ParticipantTournamentDTO, ParticipantTournamentModel>(p))
                                                                                       .ToList();

                element = Add(sports, tournamentBaseModels, participantTournamentModels);
            }
            else
            {
                List <ServiceMessage> messages = new List <ServiceMessage>()
                {
                    sportServiceMessage,
                    tournamentServiceMessage,
                    participantServiceMessage
                };

                ErrorViewModel viewModel = new ErrorViewModel(messages);
                ErrorControl   control   = new ErrorControl(viewModel);

                element = control;
            }

            return(element);
        }
예제 #6
0
        public UIElement GetAddElement()
        {
            UIElement element = null;

            DataServiceMessage <IEnumerable <string> > sportServiceMessage;
            DataServiceMessage <IEnumerable <TournamentDisplayDTO> > tournamentServiceMessage;
            DataServiceMessage <IEnumerable <EventDisplayDTO> >      eventServiceMessage;

            using (ISportService service = factory.CreateSportService())
            {
                sportServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message);
            }
            using (ITournamentService service = factory.CreateTournamentService())
            {
                tournamentServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message);
            }
            using (IEventService service = factory.CreateEventService())
            {
                eventServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message);
            }

            if (sportServiceMessage.IsSuccessful && tournamentServiceMessage.IsSuccessful && eventServiceMessage.IsSuccessful)
            {
                IEnumerable <TournamentBaseDTO> tournamentDTOs = tournamentServiceMessage.Data.AsEnumerable <TournamentBaseDTO>();
                IEnumerable <EventBaseDTO>      eventDTOs      = eventServiceMessage.Data.AsEnumerable <EventBaseDTO>();

                IEnumerable <string> sports = sportServiceMessage.Data;
                IEnumerable <TournamentBaseModel> tournaments = tournamentDTOs
                                                                .Select(t => Mapper.Map <TournamentBaseDTO, TournamentBaseModel>(t));
                IEnumerable <EventBaseModel> events = eventDTOs
                                                      .Select(e => Mapper.Map <EventBaseDTO, EventBaseModel>(e));

                element = Add(sports, tournaments, events);
            }
            else
            {
                List <ServiceMessage> messages = new List <ServiceMessage>()
                {
                    sportServiceMessage,
                    tournamentServiceMessage,
                    eventServiceMessage
                };

                ErrorViewModel viewModel = new ErrorViewModel(messages);
                ErrorControl   control   = new ErrorControl(viewModel);

                element = control;
            }

            return(element);
        }
예제 #7
0
        public override IEnumerable <string> GetAll()
        {
            IEnumerable <string> sportNames = null;

            using (ISportService service = factory.CreateSportService())
            {
                DataServiceMessage <IEnumerable <string> > serviceMessage = service.GetAll();

                RaiseReveivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);
                sportNames = serviceMessage.IsSuccessful ? serviceMessage.Data : new List <string>();
            }

            return(sportNames);
        }
예제 #8
0
        public UIElement GetAddElement()
        {
            UIElement element = null;

            DataServiceMessage <IEnumerable <string> > countryServiceMessage;
            DataServiceMessage <IEnumerable <string> > sportServiceMessage;

            using (ICountryService service = factory.CreateCountryService())
            {
                countryServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(countryServiceMessage.IsSuccessful, countryServiceMessage.Message);
            }
            using (ISportService service = factory.CreateSportService())
            {
                sportServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message);
            }

            if (countryServiceMessage.IsSuccessful && sportServiceMessage.IsSuccessful)
            {
                IEnumerable <string> countries = countryServiceMessage.Data;
                IEnumerable <string> sports    = sportServiceMessage.Data;

                element = Create(countries, sports);
            }
            else
            {
                List <ServiceMessage> messages = new List <ServiceMessage>()
                {
                    countryServiceMessage,
                    sportServiceMessage
                };

                ErrorViewModel viewModel = new ErrorViewModel(messages);
                ErrorControl   control   = new ErrorControl(viewModel);

                element = control;
            }

            return(element);
        }
예제 #9
0
        public UIElement GetAddElement()
        {
            DataServiceMessage <string> bookmakerServiceMessage;
            DataServiceMessage <IEnumerable <ClientDisplayDTO> >      clientServiceMessage;
            DataServiceMessage <IEnumerable <string> >                sportServiceMessage;
            DataServiceMessage <IEnumerable <TournamentDisplayDTO> >  tournamentServiceMessage;
            DataServiceMessage <IEnumerable <EventDisplayDTO> >       eventServiceMessage;
            DataServiceMessage <IEnumerable <CoefficientDisplayDTO> > coefficientServiceMessage;

            using (IBookmakerService service = factory.CreateBookmakerService())
            {
                bookmakerServiceMessage = service.GetLoggedInBookmakersPhoneNumber();
                RaiseReceivedMessageEvent(bookmakerServiceMessage);
            }
            using (IClientService service = factory.CreateClientService())
            {
                clientServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(clientServiceMessage);
            }
            using (ISportService service = factory.CreateSportService())
            {
                sportServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(sportServiceMessage);
            }
            using (ITournamentService service = factory.CreateTournamentService())
            {
                tournamentServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(tournamentServiceMessage);
            }
            using (IEventService service = factory.CreateEventService())
            {
                eventServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(eventServiceMessage);
            }
            using (ICoefficientService service = factory.CreateCoefficientService())
            {
                coefficientServiceMessage = service.GetAll();
                RaiseReceivedMessageEvent(coefficientServiceMessage);
            }

            bool success =
                bookmakerServiceMessage.IsSuccessful &&
                clientServiceMessage.IsSuccessful &&
                sportServiceMessage.IsSuccessful &&
                tournamentServiceMessage.IsSuccessful &&
                eventServiceMessage.IsSuccessful &&
                coefficientServiceMessage.IsSuccessful;

            UIElement element;

            if (success)
            {
                string bookmakerPhoneNumber = bookmakerServiceMessage.Data;
                IEnumerable <ClientDisplayModel> clients = clientServiceMessage
                                                           .Data
                                                           .Select(client => Mapper.Map <ClientDisplayDTO, ClientDisplayModel>(client));
                IEnumerable <string> sports = sportServiceMessage.Data;
                IEnumerable <TournamentDisplayModel> tournaments = tournamentServiceMessage
                                                                   .Data
                                                                   .Select(tournament => Mapper.Map <TournamentDisplayDTO, TournamentDisplayModel>(tournament));
                IEnumerable <EventDisplayModel> events = eventServiceMessage
                                                         .Data
                                                         .Select(_event => Mapper.Map <EventDisplayDTO, EventDisplayModel>(_event));
                IEnumerable <CoefficientDisplayModel> coefficients = coefficientServiceMessage
                                                                     .Data
                                                                     .Select(coefficient => Mapper.Map <CoefficientDisplayDTO, CoefficientDisplayModel>(coefficient));

                element = Add(bookmakerPhoneNumber, clients, sports, tournaments, events, coefficients);
            }
            else
            {
                List <ServiceMessage> messages = new List <ServiceMessage>()
                {
                    bookmakerServiceMessage,
                    clientServiceMessage,
                    sportServiceMessage,
                    tournamentServiceMessage,
                    eventServiceMessage,
                    coefficientServiceMessage
                };

                ErrorViewModel viewModel = new ErrorViewModel(messages);
                ErrorControl   control   = new ErrorControl(viewModel);

                element = control;
            }

            return(element);
        }