Ejemplo n.º 1
0
        public ActionResult TournamentManager()
        {
            var result      = _tournamentService.GetAll();
            var tournaments = Mapper.Map <IEnumerable <Tournament>, IEnumerable <TournamentViewModel> >(result);

            return(View(tournaments));
        }
Ejemplo n.º 2
0
        public JsonResult TournamentManager()
        {
            var result      = _tournamentService.GetAll();
            var tournaments = Mapper.Map <IEnumerable <Tournament>, IEnumerable <TournamentViewModel> >(result);

            return(Json(tournaments, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public PartialViewResult GetTournaments(int?page = 1, string active = "")
        {
            var        tournaments    = tournamentService.GetAll().OrderBy(x => x.DateFrom);
            HttpCookie pageSizeCookie = Request.Cookies["_pageSize"];
            int        pageSize       = Convert.ToInt16(pageSizeCookie.Value);

            var tab = new TableViewModel <Tournament>()
            {
                TableData           = tournaments.ToPagedList((int)page, pageSize),
                Active              = active,
                Controller          = "Tournaments",
                ChildController     = "Tournaments",
                TournamentOrganizer = "",
                TournamentStatus    = null
            };

            return(PartialView("_Tournaments", tab));
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public IEnumerable <Models.Tournament> GetAll()
 {
     return(_service.GetAll());
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public IActionResult LoadData()
        {
            try
            {
                var draw = HttpContext.Request.Form["draw"].FirstOrDefault();

                // Skip number of Rows count
                var start = Request.Form["start"].FirstOrDefault();

                // Paging Length 10,20
                var length = Request.Form["length"].FirstOrDefault();

                // Sort Column Name
                var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault();

                // Sort Column Direction (asc, desc)
                var sortColumnDirection = Request.Form["order[0][dir]"].FirstOrDefault();

                // Search Value from (Search box)
                var searchValue = Request.Form["search[value]"].FirstOrDefault();

                //Paging Size (10, 20, 50,100)
                int pageSize = length != null?Convert.ToInt32(length) : 0;

                int skip = start != null?Convert.ToInt32(start) : 0;

                int recordsTotal = 0;

                // getting all Customer data
                var customerData = _tournamentService.GetAll();
                //Sorting
                if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDirection)))
                {
                    var discountFilterExpression = GetExpression <Core.Models.TournamentModel>(sortColumn);

                    if (sortColumnDirection == "desc")
                    {
                        customerData.OrderByDescending(discountFilterExpression);
                    }
                    else
                    {
                        customerData = customerData.OrderBy(discountFilterExpression);
                    }
                }

                //Search
                if (!string.IsNullOrEmpty(searchValue))
                {
                    customerData = customerData.Where(m => m.Name.ToLower().Contains(searchValue.ToLower()));
                }

                //total number of rows counts
                recordsTotal = customerData.Count();
                //Paging
                var data = customerData.Skip(skip).Take(pageSize).ToList();
                //Returning Json Data
                return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data },
                            new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    Converters = { new DateTimeConverter() }
                }));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <IActionResult> Get()
        {
            var tournaments = _tournamentService.GetAll().ToList();

            return(Json(Mapper.Map <IEnumerable <Tournament>, IEnumerable <TournamentViewModel> >(tournaments)));
        }
Ejemplo n.º 10
0
        public override IEnumerable <TournamentDisplayModel> GetAll()
        {
            IEnumerable <TournamentDisplayModel> tournamentModels = null;

            using (ITournamentService service = factory.CreateTournamentService())
            {
                DataServiceMessage <IEnumerable <TournamentDisplayDTO> > serviceMessage = service.GetAll();
                RaiseReveivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);

                if (serviceMessage.IsSuccessful)
                {
                    IEnumerable <TournamentDisplayDTO> tournamentDTOs = serviceMessage.Data;
                    tournamentModels = tournamentDTOs.Select(tournamentDTO => Mapper.Map <TournamentDisplayDTO, TournamentDisplayModel>(tournamentDTO));
                }
                else
                {
                    tournamentModels = new List <TournamentDisplayModel>();
                }
            }

            return(tournamentModels);
        }
Ejemplo n.º 11
0
        //[Authorize(Roles = PlayerRolesConst.MainPlayer)]
        public IActionResult GetAll()
        {
            var result = _tournamentService.GetAll();

            return(Ok(result));
        }
 public async Task <IEnumerable <Tournament> > GetAll()
 {
     return(await _tournamentService.GetAll());
 }
Ejemplo n.º 13
0
 public ActionResult <IEnumerable <TournamentDto> > GetAll([FromQuery] TournamentResourceParameters tournamentResourceParameters)
 {
     //throw new Exception("Test Exception");
     return(Ok(tournamentService.GetAll(tournamentResourceParameters)));
 }
 public IActionResult Get()
 {
     return(Ok(_mapper.ToDtoArray(_tournamentService.GetAll())));
 }