Exemplo n.º 1
0
 private static List<RawCompetitor> GetRawCompetitorInt(BrokerType brokerType, LanguageType languageType, SportType sportType, GenderType genderType, string[] names)
 {
     if (genderType == GenderType.Unknown) {
         _logger.Error("{0}: {1}", names.StrJoin(", "), genderType);
     }
     var competitorsRaw = RawCompetitor.DataSource.FilterByLanguage(languageType).FilterBySportType(sportType).FilterByBroker(brokerType)
                                         .FilterByNameCompetitor(names)
                                         .FilterByGender(genderType,
                 RawCompetitor.Fields.CompetitoruniqueID,
                 RawCompetitor.Fields.Name,
                 RawCompetitor.Fields.Linkstatus);
     if (competitorsRaw.Count > 1) {
         var groupBy = competitorsRaw.Where(c => c.CompetitoruniqueID != default(int)).GroupBy(c => c.CompetitoruniqueID).ToArray();
         if (groupBy.Length > 1) {
             _logger.Error("{0} {1} {2} {3} {4} <=> {5}", brokerType, sportType, genderType,
                 competitorsRaw.Select(cr => cr.ID).StrJoin(", "), names.StrJoin(", "), groupBy.Select(g => g.Select(ge => ge.Name).StrJoin(", ")).StrJoin(" | "));
             return groupBy.First().ToList();
         }
         if (groupBy.Length == 1) {
             foreach (var rawCompetitor in competitorsRaw.Where(cr => cr.CompetitoruniqueID == default(int))) {
                 rawCompetitor.CompetitoruniqueID = groupBy[0].Key;
                 rawCompetitor.Save();
             }
         }
     }
     return CreateRawCompetitor(names, competitorsRaw, brokerType, languageType, sportType, genderType);
 }
Exemplo n.º 2
0
 private ActionResult BuildActionResult(SportType sportType, Dictionary<DateTime, List<Dictionary<BetOddType, BetItemTransport>>> data)
 {
     return new ActionResultCached(data != null,
         () => data.MaxOrDefault(d => d.Key, DateTime.MinValue),
         () => {
             var res = new List<Dictionary<string, double>>();
             var addDraw = BetHelper.SportTypeWithOdds[sportType].Contains(BetOddType.Draw);
             data
                 .OrderBy(d => d.Key)
                 .Each(betItems => {
                     var list = betItems.Value;
                     var dict = new Dictionary<string, double> {
                         {"d", (betItems.Key - ProjectBConsts.DefaultLinuxUtc).TotalMilliseconds},
                         {"w1", BetOddInterfaceHelper.GetOddValue(sportType, BetOddType.Win1, list, Enumerable.Max)},
                         {"w2", BetOddInterfaceHelper.GetOddValue(sportType, BetOddType.Win2, list, Enumerable.Max)},
                         {"r1x2", BetOddInterfaceHelper.GetBetOddRoi(RoiType.Roi1X2, sportType, list)},
                         {"h1", BetOddInterfaceHelper.GetOddValue(sportType, BetOddType.Handicap1, list, Enumerable.Max)},
                         {"h2", BetOddInterfaceHelper.GetOddValue(sportType, BetOddType.Handicap2, list, Enumerable.Max)},
                         {"rh", BetOddInterfaceHelper.GetBetOddRoi(RoiType.RoiHandicap, sportType, list)},
                         {"tu", BetOddInterfaceHelper.GetOddValue(sportType, BetOddType.TotalUnder, list, Enumerable.Max)},
                         {"to", BetOddInterfaceHelper.GetOddValue(sportType, BetOddType.TotalOver, list, Enumerable.Max)},
                         {"rt", BetOddInterfaceHelper.GetBetOddRoi(RoiType.RoiTotal, sportType, list)},
                     };
                     if (addDraw) {
                         dict["x"] = BetOddInterfaceHelper.GetOddValue(sportType, BetOddType.Draw, list, Enumerable.Max);
                     }
                     res.Add(dict);
                 });
             return new JsonResult {
                 Data = res
             };
         });
 }
Exemplo n.º 3
0
        public Match(SportType sport, League league, DateTime dateTime, string homeTeam, string visitorTeam)
        {
            /*
             * var dateToBeChecked = dateTime.AddHours(2);
             *
             * if (DateTime.Now > dateToBeChecked)
             * {
             *  throw new ArgumentException("Cannot add match that is expired.");
             * }
             */

            if (homeTeam == visitorTeam)
            {
                throw new ArgumentException(EngineConstants.SameTeamsInMatchErrorMessage);
            }

            this.Sport       = sport;
            this.League      = league;
            this.Date        = dateTime;
            this.HomeTeam    = homeTeam;
            this.VisitorTeam = visitorTeam;

            this.Id    = lastUsedId + 1;
            lastUsedId = this.Id;

            this.Bets    = new List <IBet>();
            this.Results = new Dictionary <ResultType, IResult>();
        }
Exemplo n.º 4
0
        public long CreateLeague(string name, long userId, SportType sport)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new BusinessException(ErrorCodes.LeagueNameRequired, "League name is required.");
            }

            var leagueName = name.Trim();

            if (!IsValidateLeagueName(leagueName))
            {
                throw new BusinessException(ErrorCodes.InvalidLeagueName, "League name must be between 5 and 50 alphanumeric characters");
            }

            var league = new League
                {
                    CreatorUserId = userId,
                    Name = leagueName,
                    OwnerUserId = userId,
                    Sport = sport
                };

            var leagueId = _leagueRepository.CreateLeague(league);

            _leagueRepository.AddMember(leagueId, userId);

            return leagueId;
        }
Exemplo n.º 5
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        ItemGenerator myTarget = (ItemGenerator)target;

        EditorGUILayout.PropertyField(state_Prop);
        SportType st = (SportType)state_Prop.enumValueIndex;

        switch (st)
        {
        case SportType.DOWNHILL:
            EditorGUILayout.PropertyField(dh_playerController, true, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(dh_standardChangeMeters, new GUIContent("dh_standardChangeMeters"), true);
            EditorGUILayout.PropertyField(dh_intervalMeters, new GUIContent("dh_intervalMeters"), true);
            EditorGUILayout.PropertyField(dh_itemAreas, new GUIContent("dh_itemAreas"), true);
            EditorGUILayout.PropertyField(dh_numPerGenerates, new GUIContent("dh_numPerGenerates"), true);
            break;

        case SportType.SKELETON:

            break;

        case SportType.SKIJUMP:
            EditorGUILayout.PropertyField(sj_playerController, true, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(sj_standardChangeMeter, new GUIContent("sj_standardChangeMeter"), true);
            EditorGUILayout.PropertyField(sj_intervalMeter, new GUIContent("sj_intervalMeter"), true);
            EditorGUILayout.PropertyField(sj_numPerGenerate, new GUIContent("sj_numPerGenerate"), true);
            break;
        }

        EditorGUILayout.PropertyField(items, new GUIContent("items"), true);
        EditorGUILayout.PropertyField(parent, new GUIContent("parent"), true);
        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 6
0
        public void ResolveNamingNeutralTest()
        {
            IUnitOfWork unit = new EFUnitOfWork(this.databaseSportsContext);

            SportType football = new SportType {
                Name = "Football"
            };
            SportType sport = unit.GetRepository <SportType>()
                              .Get(x => x.Name.ToUpper() == football.Name.ToUpper())
                              .FirstOrDefault();

            Conformity expConf = new Conformity
            {
                InputName   = "Ст. Этьен",
                ExistedName = "Сент-Этьен"
            };

            Team neutralTeam = new Team
            {
                Name      = "Ст. Этьен",
                SportType = sport
            };

            NamingMatcher matcher = new NamingMatcher(unit);

            List <Conformity> neutralConformities = matcher.ResolveNaming(neutralTeam);

            Conformity newConf = neutralConformities.FirstOrDefault();

            Assert.AreEqual(expConf.InputName, newConf.InputName);
            Assert.AreEqual(expConf.ExistedName, newConf.ExistedName);
        }
Exemplo n.º 7
0
        public void Delete(int ID)
        {
            SportType selectedItem = _SportType.Find(ID);

            selectedItem.IsDeleted = true;
            selectedItem.UpdatedOn = DateTime.Now;
        }
Exemplo n.º 8
0
        public void ResolveNamingNegativeTest()
        {
            IUnitOfWork unit = new EFUnitOfWork(this.databaseSportsContext);

            SportType football = new SportType {
                Name = "Football"
            };
            SportType sport = unit.GetRepository <SportType>()
                              .Get(x => x.Name.ToUpper() == football.Name.ToUpper())
                              .FirstOrDefault();

            Team negativeTeam = new Team
            {
                Name      = "Металлист",
                SportType = sport,
                Names     = new List <TeamName>()
            };

            NamingMatcher matcher = new NamingMatcher(unit);

            List <Conformity> negativeConformities = matcher.ResolveNaming(negativeTeam);

            Assert.IsNull(negativeConformities);

            Team team = unit.GetRepository <Team>()
                        .Get((x) => x.Id == negativeTeam.Id)
                        .FirstOrDefault();

            Assert.AreEqual(negativeTeam, team);
        }
Exemplo n.º 9
0
        //-----------------------------------------------------

        private IActionResult UpdatGet(int clientId)
        {
            var clt   = _clientManager.GetClient(clientId);
            var cltVM = clt.ToClientVM();

            // 2. Map all derived fields ---------
            cltVM.ClientFullName    = clt.FirstName + "  " + clt.LastName;
            cltVM.AgeInDays         = (int)(DateTime.Today.Subtract(clt.BirthDate)).TotalDays;
            cltVM.NrofPrescriptions = _clientManager.GetNrOfPrescrPerClient(clt.Id);
            cltVM.DoctorFullName    = _clientManager.DoctorFullName(clt.DoctorId);

            // Alle landen toevoegen aan UPDATE scherm, ivm dropdownlist
            // TODO: hoe toon ik het land van deze client als default?
            cltVM.Countries = _countryManager.GetAllCountries();

            CreateListOfZodiacs(cltVM); // cltVM is call by reference

            //  zoek index in Enum op van de betreffende sterrenbeeld
            //  zodat deze als eerste wordt getoond in de view:
            AstrologyZodiacSign zodiacSign = (AstrologyZodiacSign)Enum.Parse(typeof(AstrologyZodiacSign), clt.AstrologyZodiacSign);

            cltVM.ZodiacId = (int)zodiacSign;

            CreateListOfSportTypes(cltVM); // cltVM is call by reference

            //  zoek index in Enum op van de betreffende sterrenbeeld
            //  zodat deze als eerste wordt getoond in de view:
            SportType sportType = (SportType)Enum.Parse(typeof(SportType), clt.TypeOfSporter);

            cltVM.SportTypeId = (int)sportType;

            return(View(cltVM));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Query to generate a list of activities which match given criteria
        /// </summary>
        /// <param name="userId">ASP.NET Identity Id</param>
        /// <param name="sport">Run, Ride, Swim, Other, All</param>
        /// <param name="start">Beginning of date range</param>
        /// <param name="end">End of date range</param>
        /// <returns></returns>
        public IQueryable <ActivityDto> GetSportSummaryQuery(string userId, SportType sport, DateTime start, DateTime end)
        {
            ActivityRepository activityRepo = new ActivityRepository(_context);

            IQueryable <ActivityDto> activityQuery = activityRepo.ActivitiesBySport(userId, sport)
                                                     .Include(r => r.ActivityType)
                                                     .Where(r => r.Start >= start && r.Start <= end)
                                                     .Select(r => new ActivityDto
            {
                Id                = r.Id,
                Name              = r.Name,
                ActivityTypeId    = r.ActivityTypeId,
                MovingTime        = r.MovingTime != null ? r.MovingTime.Value : new TimeSpan(0, 0, 0),
                Distance          = r.Distance,
                SufferScore       = r.SufferScore != null ? r.SufferScore.Value : 0,
                Calories          = r.Calories,
                ElevationGain     = r.ElevationGain,
                Start             = r.Start,
                StartDateLocal    = r.StartDateLocal,
                HasMap            = r.StartLatitude != null ? true : false,
                IsRide            = r.ActivityType.IsRide,
                IsRun             = r.ActivityType.IsRun,
                IsSwim            = r.ActivityType.IsSwim,
                IsOther           = r.ActivityType.IsOther,
                DetailsDownloaded = r.DetailsDownloaded,
                HasPowerMeter     = r.HasPowerMeter,
                TSS               = r.TSS != null ? r.TSS : 0
            });

            return(activityQuery);
        }
Exemplo n.º 11
0
        public bool SecondaryEvenTileExists(SportType sport, int eventId)
        {
            var tileParms = string.Format(EventSecondaryTileQuery, eventId, (int)sport);
            var secondaryTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(tileParms));

            return secondaryTile != null;
        }
        public async Task <SportType> AddAsync(SportType newSportType, CancellationToken ct = default)
        {
            this._dbContext.SportTypes.Add(newSportType);
            await this._dbContext.SaveChangesAsync(ct);

            return(newSportType);
        }
        public async Task <IActionResult> Edit(string id, [Bind("Name,Description")] SportType sportType)
        {
            if (id != sportType.Name)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sportType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SportTypeExists(sportType.Name))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sportType));
        }
Exemplo n.º 14
0
        private static List<RawCompetitor> CreateRawCompetitor(string[] names, List<RawCompetitor> competitorsRaw, BrokerType brokerType, LanguageType languageType, SportType sportType, GenderType genderType)
        {
            var existNames = competitorsRaw.Select(cr => cr.Name).ToList();
            names = names
                .Where(name => !existNames.Contains(name))
                .ToArray();
            if (names.Any()) {
                var lastCompetitorUniqueID = competitorsRaw.Any()
                    ? competitorsRaw.First().CompetitoruniqueID
                    : default(int);
                var raw = competitorsRaw;
                names
                    .Where(name => !raw.Any(c => c.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)))
                    .Each(name => {
                        RawCompetitor competitorRaw = null;
                        try {
                            competitorRaw = BrokerEntityIfaceCreator.CreateEntity<RawCompetitor>(brokerType, languageType, sportType, genderType, LinkEntityStatus.Unlinked, new[] { name },
                                competitor => {
                                    if (lastCompetitorUniqueID != default(int)) {
                                        competitor.CompetitoruniqueID = lastCompetitorUniqueID;
                                        competitor.Linkstatus = LinkEntityStatus.LinkByStatistics | LinkEntityStatus.Linked;
                                    }
                                });
                            competitorRaw.Save();
                            raw.Add(competitorRaw);
                        } catch (Exception ex) {
                            _logger.Error("{0}\r\n{1}", competitorRaw?.ToString(), ex);
                            throw;
                        }
                    });
            }

            return competitorsRaw;
        }
Exemplo n.º 15
0
        internal IQueryable <Activity> ActivitiesBySport(string userId, SportType sport)
        {
            // get activities which fall into the selected weeks.
            var activitiesQuery = _context.Activity
                                  .Include(r => r.ActivityType)
                                  .Include(r => r.Athlete)
                                  .Where(r => r.Athlete.UserId == userId);

            if (sport == SportType.Ride)
            {
                return(activitiesQuery.Where(r => r.ActivityType.IsRide));
            }
            else if (sport == SportType.Run)
            {
                return(activitiesQuery.Where(r => r.ActivityType.IsRun));
            }
            else if (sport == SportType.Swim)
            {
                return(activitiesQuery.Where(r => r.ActivityType.IsSwim));
            }
            else if (sport == SportType.Other)
            {
                return(activitiesQuery.Where(r => r.ActivityType.IsOther));
            }
            else
            {
                return(activitiesQuery);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Calculate Daily information for a given sport.
        /// </summary>
        /// <param name="sport"></param>
        private void Calculate(SportType sport)
        {
            int     sequence           = 0;
            decimal runningYTDDistance = 0;

            foreach (YearlyDetailsDayInfo i in _details.Where(a => a.Sport == sport))
            {
                if (i.Date.Month == 1 && i.Date.Day == 1)
                {
                    runningYTDDistance = 0;
                }

                runningYTDDistance += i.Distance;
                i.YTDDistance       = runningYTDDistance;

                if (i.Distance > 0)
                {
                    i.Sequence = ++sequence;
                }
                else
                {
                    sequence = 0;
                }
            }
        }
        public async Task <bool> UpdateSportTypeAsync(SportTypeViewModel sportTypeToUpdate, CancellationToken ct = default(CancellationToken))
        {
            SportType sportType = await _sportTypeRepository.GetByIdAsync(sportTypeToUpdate.Id, ct);

            if (sportType == null)
            {
                return(false);
            }

            sportType.Name   = sportTypeToUpdate.Name;
            sportType.Active = sportTypeToUpdate.Active;

            // if sport type successfully updated, update all of its leagues
            if (await this._sportTypeRepository.UpdateAsync(sportType, ct))
            {
                // when the sport type name changes we also need to update all of the associated leagues type property
                // since the type property on the league represents the name of the sport
                List <LeagueViewModel> leagues = await GetLeaguesBySportTypeIdAsync(sportType.Id);

                List <LeagueViewModel> updatedLeagues = new List <LeagueViewModel>();

                foreach (LeagueViewModel league in leagues)
                {
                    league.Type = sportTypeToUpdate.Name;
                    updatedLeagues.Add(league);
                }

                return(await UpdateLeaguesAsync(updatedLeagues, ct));
            }

            // if updating sport type failed
            return(false);
        }
Exemplo n.º 18
0
 private static CompetitionItemRoiRow[] BuildResult(DbStoredProc proc, SportType sportType, int[] competitionUniqueIDs, BrokerType[] brokerTypes)
 {
     if (brokerTypes != null) {
         proc = proc.WithParam("argbrokerids", brokerTypes.Select(b => (short)b), DbType.Int16);
     }
     if (competitionUniqueIDs != null) {
         proc = proc.WithParam("argcompetitionuniqueids", competitionUniqueIDs, DbType.Int32);
     }
     if (sportType != SportType.Unknown) {
         proc = proc.WithParam("argsporttype", (short) sportType);
     }
     var data = proc.MultiRowExec(DatabaseActions.GetAdapter(TargetDB.MASTER), "fn_getbetroi").Data;
     var result = new CompetitionItemRoiRow[data.Count];
     for (var i = 0; i < result.Length; i++) {
         var row = data[i];
         var betData = (int[])row[1];
         var betIDs = new Dictionary<BetOddType, int>();
         for (var j = 0; j < betData.Length; j+=2) {
             betIDs[(BetOddType) (short) betData[j]] = betData[j + 1];
         }
         result[i] = new CompetitionItemRoiRow {
             ID = (int)row[0],
             BetIDs = betIDs,
             Roi = (float) row[2],
             RoiType = (RoiType) (short) row[3]
         };
     }
     return result;
 }
Exemplo n.º 19
0
        private static Player GetPlayer(DirectoryInfo directory, SportType sportType)
        {
            var           fullPlayerName = directory.Name;
            var           split          = fullPlayerName.Split(" ");
            List <Player> players;
            Player        player;
            string        firstName = split[0];
            string        lastName  = split.Length > 1 ? split[1] : "";

            players = _playerDBService.Get(firstName, lastName);
            if (players == null || players.Count == 0)
            {
                players = _playerDBService.Get(lastName, firstName);
            }
            if (players != null && players.Count > 0)
            {
                player = players[0];
            }
            else
            {
                player = _playerDBService.Create(new Player
                {
                    Id        = Guid.NewGuid().ToString(),
                    FirstName = firstName,
                    LastName  = lastName,
                    SportType = sportType
                });
            }

            return(player);
        }
        /// <summary>
        ///     Saves sport to a database
        /// </summary>
        /// <param name="o">Leave it empty</param>
        private async void SaveSportType(object o)
        {
            SportType = new SportType
            {
                Id          = SportTypeId ?? -1,
                Name        = SportTypeName,
                Description = SportTypeDescription
            };
            _cts.Cancel();
            _cts      = new CancellationTokenSource();
            ErrorText = "Trwa zapisywanie...";
            var success = await _sportTypeProxy.SaveSportType(SportType);

            if (success)
            {
                ErrorText            = "Zapisano.";
                SportTypeDescription = null;
                SportTypeName        = null;
                SportTypeId          = null;
                await RemoveErrorMesage(_cts.Token);
            }
            else
            {
                ErrorText = "Zapisywanie nie powidoło się. Pamiętaj, że nazwa musi być unikalna.";
                await RemoveErrorMesage(_cts.Token);
            }
        }
Exemplo n.º 21
0
        private Tuple<string, string> GetImages(SportType sport )
        {
            var frontTile = string.Format(FrontImagePath, sport.ToString());
            var backTile = string.Format(BackImagePath, sport.ToString());

            return Tuple.Create(frontTile, backTile);
        }
Exemplo n.º 22
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        Item myTarget = (Item)target;

        EditorGUILayout.PropertyField(state_Prop);
        SportType st = (SportType)state_Prop.enumValueIndex;

        switch (st)
        {
        case SportType.DOWNHILL:
            EditorGUILayout.PropertyField(item_dh, true, new GUILayoutOption[0]);
            break;

        case SportType.SKELETON:
            EditorGUILayout.PropertyField(item_st, true, new GUILayoutOption[0]);
            break;

        case SportType.SKIJUMP:
            EditorGUILayout.PropertyField(item_sj, true, new GUILayoutOption[0]);
            break;
        }
        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 23
0
        public void Init()
        {
            this.sportType = new SportType {
                Id = 0, Name = "Football"
            };

            Team team1 = new Team {
                Id = 0, Name = "Team_1", SportType = this.sportType
            };
            Team team2 = new Team {
                Id = 1, Name = "Team_2", SportType = this.sportType
            };
            Team team3 = new Team {
                Id = 2, Name = "Team_3", SportType = this.sportType
            };

            this.res1 = new Result {
                Id = 0, Team = team1, Score = 3
            };
            this.res2 = new Result {
                Id = 1, Team = team2, Score = 1
            };
            this.res3 = new Result {
                Id = 2, Team = team3, Score = 5
            };

            this.sportEvent1 = new SportEvent {
                Id = 0
            };
            this.sportEvent1.Results = new List <Result>();

            this.sportEvent2 = new SportEvent {
                Id = 1
            };
            this.sportEvent2.Results = new List <Result>();

            this.sportEvent3 = new SportEvent {
                Id = 2
            };
            this.sportEvent3.Results = new List <Result>();

            DateTime date = new DateTime(2016, 11, 21, 16, 30, 0);

            this.sportEvent1.Date = date;
            this.sportEvent2.Date = date;
            this.sportEvent3.Date = date;

            this.sportEvent1.SportType = this.sportType;
            this.sportEvent2.SportType = this.sportType;
            this.sportEvent3.SportType = this.sportType;

            this.sportEvent1.Results.Add(this.res1);
            this.sportEvent1.Results.Add(this.res2);
            this.sportEvent2.Results.Add(this.res1);
            this.sportEvent2.Results.Add(this.res2);

            this.sportEvent3.Results.Add(this.res1);
            this.sportEvent3.Results.Add(this.res3);
        }
Exemplo n.º 24
0
 public static CompetitionItemRoiRow[] GetDataForDate(DateTime fromDate, DateTime toDate, SportType sportType = SportType.Unknown, int[] competitionUniqueIDs = null, BrokerType[] brokerTypes = null)
 {
     var proc = new DbStoredProc()
         .NotRepeatable()
         .WithParam("argcompetitionmindate", fromDate)
         .WithParam("argcompetitionmaxdate", toDate);
     return BuildResult(proc, sportType, competitionUniqueIDs, brokerTypes);
 }
        public void Enum2()
        {
            SportType mySport   = SportType.Basketball;
            SportType yourSport = SportType.Football;

            Console.WriteLine(mySport);
            Console.WriteLine(yourSport);
        }
        public IList<PracticeDrillDto> ForSport(SportType sportType)
        {
            var results = from drill in DB.Database.Query<PracticeDrillDto, int, int>(CoachesDatabase.SportTypeDataIndex)
                          where drill.Index == (int)sportType
                          select drill.LazyValue.Value;

            return results.ToList();
        }
Exemplo n.º 27
0
 /// <summary>
 /// Find daily average distance for a given sport/year
 /// </summary>
 /// <param name="sport"></param>
 /// <param name="year"></param>
 /// <returns></returns>
 public decimal DailyAverage(SportType sport, int?year)
 {
     return(_details
            .Where(a => sport == SportType.All ? true : a.Sport == sport)
            .Where(a => year == null ? true : a.Date.Year == year.Value)
            .Select(a => a.Distance)
            .DefaultIfEmpty()
            .Average());
 }
Exemplo n.º 28
0
 /// <summary>
 /// Find max sequnce for a given sport (and optionally year).
 /// </summary>
 /// <param name="sport"></param>
 /// <param name="year"></param>
 /// <returns></returns>
 public int MaxSequence(SportType sport, int?year)
 {
     return(_details
            .Where(a => sport == SportType.All ? true : a.Sport == sport)
            .Where(a => year == null ? true : a.Date.Year == year.Value)
            .Select(a => a.Sequence)
            .DefaultIfEmpty()
            .Max());
 }
 /// <summary>
 ///     Conversion from Data Access to dto Method
 /// </summary>
 /// <param name="d">Data Access Sport Type Object</param>
 /// <returns>dto Sport Type</returns>
 public static DtoSportType DataAccsessToDto(SportType d)
 {
     return(new DtoSportType
     {
         Id = d.id,
         Name = d.name,
         Description = d.description
     });
 }
Exemplo n.º 30
0
 public Competition(string name, string place, IEnumerable <Team> teams, DateTime startDate, SportType type, Uri liveUri)
 {
     Name      = name;
     Place     = place;
     StartDate = startDate;
     SportType = type;
     LiveUri   = liveUri;
     Teams     = teams.ToImmutableArray();
 }
Exemplo n.º 31
0
 /// <summary>
 ///     Conversion from DTO to View Model Method
 /// </summary>
 /// <param name="d">View Model Sport Type Object</param>
 /// <returns>DTO Sport Type</returns>
 public static DtoSportType ViewModelToDto(SportType d)
 {
     return(new DtoSportType
     {
         Id = d.Id,
         Name = d.Name,
         Description = d.Description
     });
 }
Exemplo n.º 32
0
 public static CompetitionItemRoiRow[] GetDataForNow(float minRoi = float.MinValue, SportType sportType = SportType.Unknown, int[] competitionUniqueIDs = null, BrokerType[] brokerTypes = null)
 {
     var proc = new DbStoredProc()
         .NotRepeatable();
     if (minRoi != float.MinValue) {
         proc = proc
             .WithParam("argroimin", minRoi);
     }
     return BuildResult(proc, sportType, competitionUniqueIDs, brokerTypes);
 }
Exemplo n.º 33
0
        private void button1_Click(object sender, EventArgs e)
        {
            SportType selectSport = SportType.Football;

            IAthlete athlete = GetAthlete(selectSport);

            athlete.ChangeTeam("Chiefs");

            var team = athlete.TeamName;
        }
Exemplo n.º 34
0
        public void DeleteSecondaryTile(SportType sport, int eventId)
        {
            var tileParms = string.Format(EventSecondaryTileQuery, eventId, (int)sport);
            var secondaryTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(tileParms));

            if (secondaryTile != null)
            {
                secondaryTile.Delete();
            }
        }
Exemplo n.º 35
0
        public void Add(SportTypeModel sporttype)
        {
            var sportT = new SportType
            {
                Title     = sporttype.Title,
                IsEnabled = true
            };

            _SportType.Add(sportT);
        }
        public async Task <IActionResult> Create([Bind("Name,Description")] SportType sportType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sportType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sportType));
        }
Exemplo n.º 37
0
        private static SportLiveMatch CreateSportLiveMatch(SportType sport, string competition, HtmlNode item)
        {
            try
            {
                var evno      = item.Attributes["evno"].Value;
                var infoBlock = item.InnerHtml.GetCssNode("tbody > tr > td.td_n > a");
                var link      = infoBlock.Attributes["href"].Value;
                var teams     = CreateTeams(infoBlock);

                var result = infoBlock.InnerHtml.GetCssNode("span.score").InnerText;

                var slm = new SportLiveMatch
                {
                    EventNo     = evno,
                    SportType   = sport,
                    Competition = competition,
                    Team1       = teams[0],
                    Team2       = teams[1],
                    Result      = result,
                };

                var odds = item.InnerHtml.GetCssNodes("td").Skip(2).ToList();

                slm.Win1betKey = odds[0].InnerHtml.GetCssNode("u>a").Id;
                slm.Win1Odds   = odds[0].InnerText;

                slm.DrawbetKey = odds[1].InnerHtml.GetCssNode("u>a").Id;
                slm.DrawOdds   = odds[1].InnerText;

                slm.Win2betKey = odds[2].InnerHtml.GetCssNode("u>a").Id;
                slm.Win2Odds   = odds[2].InnerText;

                slm.Fora1Value  = odds[3].InnerText;
                slm.Fora1betKey = odds[4].InnerHtml.GetCssNode("u>a").Id;
                slm.Fora1Odds   = odds[4].InnerText;

                slm.Fora2Value  = odds[5].InnerText;
                slm.Fora2betKey = odds[6].InnerHtml.GetCssNode("u>a").Id;
                slm.Fora2Odds   = odds[6].InnerText;

                slm.TotalValue       = odds[7].InnerText;
                slm.TotalOverBetKey  = odds[8].InnerHtml.GetCssNode("u>a").Id;
                slm.TotalOverOdds    = odds[8].InnerText;
                slm.TotalUnderBetKey = odds[9].InnerHtml.GetCssNode("u>a").Id;
                slm.TotalUnderOdds   = odds[9].InnerText;

                return(slm);
            }
            catch (Exception e)
            {
            }

            return(null);
        }
Exemplo n.º 38
0
        /// <summary>
        /// Build one data model from a sport type view model.
        /// </summary>
        /// <param name="sportTypeVm">Sport type view model instance.</param>
        internal SportType BuildOneDataModelFromVm(SportTypeVm sportTypeVm)
        {
            var result = new SportType
            {
                Code        = sportTypeVm.Code,
                Name        = sportTypeVm.Name,
                Description = sportTypeVm.Description
            };

            return(result);
        }
        public async Task <SportTypeViewModel> AddSportTypeAsync(SportTypeViewModel newSportType, CancellationToken ct = default(CancellationToken))
        {
            SportType sportType = new SportType();

            sportType.Name = newSportType.Name;
            sportType      = await _sportTypeRepository.AddAsync(sportType, ct);

            newSportType.Id = sportType.Id;

            return(newSportType);
        }
Exemplo n.º 40
0
        public static SportTypeViewModel Convert(SportType sportType)
        {
            SportTypeViewModel model = new SportTypeViewModel();

            model.Id      = sportType.Id;
            model.Leagues = sportType.Leagues == null ? null : LeagueConverter.ConvertList(sportType.Leagues);
            model.Name    = sportType.Name;
            model.Active  = sportType.Active;

            return(model);
        }
Exemplo n.º 41
0
 public static ILiveResultProc GetLiveResultProc(SportType sportType)
 {
     switch (sportType) {
         case SportType.Tennis:
             return new TennisLiveResultProcessor();
         case SportType.Volleyball:
             return new VolleyballLiveResultProcessor();
         default:
             return new DefaultLiveResultProcessor();
     }
 }
Exemplo n.º 42
0
        private void Button_SubmitClicked(object sender, EventArgs e)
        {
            if (in_Name.Text != null)
            {
                SportType newSport = new SportType();
                newSport.Name  = in_Name.Text;
                newSport.Units = units_id;

                SaveAndLoad.SaveSport(newSport);
            }
            Application.Current.MainPage = Page;
        }
Exemplo n.º 43
0
        public List<Fork> SearchForks(GameInfo gameInfo, List<Game> gameList, SportType sportType)
        {
            if (gameList == null)
            {
                throw new ArgumentNullException(nameof(gameList));
            }

            var rulesList = this.rulesProvider.GiveListOfRules(sportType);
            var listForks = new List<Fork>();

            for (var i = 0; i < gameList.Count; i++)
            {
                for (var j = i + 1; j < gameList.Count; j++)
                {
                    foreach (var rule in rulesList)
                    {
                        var firstGame = gameList[i];
                        var secondGame = gameList[j];
                        var profitRate = rule.CalculateProfitRate(firstGame, secondGame);

                        if (profitRate == -1)
                        {
                            continue;
                        }

                        var fork = new Fork
                        {
                            SportType = sportType,
                            FirstGame = firstGame,
                            SecondGame = secondGame,
                            ProfitRate = profitRate,
                            FirstBetsName = firstGame.BetsName,
                            SecondBetsName = secondGame.BetsName,
                            DetectedTime = DateTime.Now
                        };

                        foreach (var firstBet in rule.FirstGameCoefTypes)
                        {
                            fork.CoefsOfFirstBets.Add(firstBet, firstGame.Coefficients[firstBet]);
                        }

                        foreach (var secondBet in rule.SecondGameCoefTypes)
                        {
                            fork.CoefsOfSecondBets.Add(secondBet, secondGame.Coefficients[secondBet]);
                        }

                        listForks.Add(fork);
                    }
                }
            }

            return listForks;
        }
Exemplo n.º 44
0
        private List<Fork> GetForks(SportType sportType, Dictionary<GameInfo, List<Game>> gameLists)
        {
            var forks = new List<Fork>();

            for (var i = 0; i < gameLists.Count; i++)
            {
                forks.AddRange(this.Searcher.SearchForks(
                        gameLists.ElementAt(i).Key,
                        gameLists.ElementAt(i).Value,
                        sportType));
            }

            return forks;
        }
Exemplo n.º 45
0
        public Dictionary<GameInfo, List<Game>> ParseExtendedGames(SportType type, List<GameInfo> gamesInfo)
        {
            var gamesAllBets = new Dictionary<SportType, List<Game>>();
            Parallel.ForEach(this.parsers,
                parser =>
                {
                    var games = parser.ParseExtendedCoefficients(gamesInfo, type);
                    if (gamesAllBets.ContainsKey(type))
                    {
                        gamesAllBets[type].AddRange(games);
                    }
                    else
                    {
                        gamesAllBets.Add(type, games.ToList());
                    }

                });
            return this.grouper.GroupGamesByGameInfo(gamesAllBets).Values.Single();
        }
Exemplo n.º 46
0
        public void CreateEventTile( SportType sport, EventType eventType, int eventId, DateTime eventDateTime, string fieldName, string teamName, string opponentName = "" )
        {
            var tileParms = string.Format(EventSecondaryTileQuery, eventId, (int)sport);
            var tileUri = string.Format("/Views/Events/{0}EventLandingPage.xaml?{1}",eventType.ToString(), tileParms);
            var tileImages = GetImages(sport);
            var frontTitle = GetTitle(eventType, teamName, opponentName);
            var backTitle = GetBackTitle(eventDateTime);

            DeleteSecondaryTile(sport, eventId);

            var newTileData = new StandardTileData
                                  {
                                      BackgroundImage = new Uri(tileImages.Item1, UriKind.RelativeOrAbsolute),
                                      Title = frontTitle,
                                      BackTitle = backTitle,
                                      BackContent = fieldName,
                                      BackBackgroundImage = new Uri(tileImages.Item2, UriKind.RelativeOrAbsolute)
                                  };

            ShellTile.Create(new Uri(tileUri, UriKind.RelativeOrAbsolute), newTileData);
        }
Exemplo n.º 47
0
 public static FullResult BuildResultFromString(SportType sportType, string resString)
 {
     FullResult result ;
     switch (sportType) {
         case SportType.Tennis:
         case SportType.Volleyball:
             var buildTennisResult = BuildFullResult(resString);
             if (buildTennisResult.SubResult.Count == 1) {
                 var tempTennisResult = new FullResult {
                     CompetitorResultOne = 0,
                     CompetitorResultTwo = 0
                 };
                 tempTennisResult.SubResult.Add(new SimpleResult {
                     CompetitorResultOne = buildTennisResult.CompetitorResultOne,
                     CompetitorResultTwo = buildTennisResult.CompetitorResultTwo
                 });
                 tempTennisResult.SubResult.AddRange(buildTennisResult.SubResult);
                 buildTennisResult = tempTennisResult;
             }
             result = buildTennisResult;
             break;
         case SportType.IceHockey:
             result = BuildFullResult(resString);
             break;
         case SportType.Basketball:
             result = BuildFullResult(resString);
             break;
         case SportType.Football:
             result = BuildFullResult(resString);
             break;
         default:
             result = BuildFullResult(resString);
             break;
     }
     return result;
 }
Exemplo n.º 48
0
 public Workout(string Name, SportType sport_type, Steps[] steps)
 {
     this.Name = Name;
     this.SportType = SportType;
     this.Steps = new List<Steps>(steps);
 }
Exemplo n.º 49
0
        public static RawTemplateObj<CompetitionSpecifyTransport> CreateCompetitionSpecifyRawObject(int rawID, int parentRawID, ICompetitionSpecify competitionSpecify, LanguageType language, SportType sportType, GenderType genderDetected)
        {
            var result = new RawTemplateObj<CompetitionSpecifyTransport>();
            result.RawObject.ID = rawID;
            result.RawObject.ParentID = parentRawID;

            result.Object.LanguageType = language;
            result.Object.SportType = sportType;
            result.Object.GenderType = genderDetected;

            result.Object.CompetitionUniqueID = competitionSpecify.CompetitionuniqueID;
            result.Object.ID = competitionSpecify.CompetitionSpecifyUniqueID;
            return result;
        }
Exemplo n.º 50
0
 private static RawCompetitionSpecify GetRawCompetitionSpecifyInt(BrokerType brokerType, LanguageType language,
     SportType sportType, GenderType genderDetected, string[] nameOrigin)
 {
     return RawCompetitionSpecify.DataSource.FilterByBroker(brokerType).FilterByLanguage(language).FilterBySportType(sportType)
         .FilterByNameCompetition(nameOrigin)
         .FilterByGender(genderDetected,
             RawCompetitionSpecify.Fields.CompetitionuniqueID,
             RawCompetitionSpecify.Fields.CompetitionspecifyuniqueID,
             RawCompetitionSpecify.Fields.Name,
             RawCompetitionSpecify.Fields.ID,
             RawCompetitionSpecify.Fields.RawCompetitionID)
         .FirstOrDefault();
 }
Exemplo n.º 51
0
        public List<Rule> GiveListOfRules(SportType sportType)
        {
            var rawRules = this.Text.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            return rawRules.Select(ParseRule).ToList();
        }
Exemplo n.º 52
0
        public static RawCompetitionSpecify CreateCompetitionSpecify(ProcessStat competitionStat, BrokerType brokerType, LanguageType language, SportType sportType, GenderType genderDetected, string[] nameOrigin, CompetitionParsed competitionToSave, GatherBehaviorMode algoMode)
        {
            var nameOriginShort = CompetitionHelper.GetShortCompetitionName(nameOrigin, sportType);
            var competitionRaw = new BrokerEntityBuilder<RawCompetition>(competitionStat)
                .SetupValidateObject(rawCompetition => rawCompetition.CompetitionuniqueID != default(int))
                .SetupGetRaw(() => {
                    return RawCompetition.DataSource.FilterByBroker(brokerType).FilterByLanguage(language).FilterBySportType(sportType)
                        .FilterByNameCompetition(nameOriginShort)
                        .FilterByGender(genderDetected, RawCompetition.Fields.CompetitionuniqueID, RawCompetition.Fields.Linkstatus).FirstOrDefault();
                })
                .SetupCreateRaw(() => BrokerEntityIfaceCreator.CreateEntity<RawCompetition>(brokerType, language, sportType, genderDetected, LinkEntityStatus.Unlinked, nameOriginShort))
                .SetupCreateOriginal(algoMode, rawCompetition => {
                    var competition = Competition.DataSource.FilterByLanguage(language).FilterBySportType(sportType)
                        .FilterByNameCompetition(nameOriginShort)
                        .FilterByGender(genderDetected, Competition.Fields.CompetitionuniqueID)
                        .FirstOrDefault();
                    if (competition == null) {
                        var competitionUnique = new CompetitionUnique {
                            IsUsed = true
                        };
                        competitionUnique.Save();
                        competition = new Competition {
                            Datecreatedutc = DateTime.UtcNow,
                            Languagetype = language,
                            SportType = sportType,
                            Name = CompetitionHelper.ListStringToName(nameOriginShort),
                            Gendertype = genderDetected,
                            CompetitionuniqueID = competitionUnique.ID
                        };
                        competition.Save();
                    }
                    rawCompetition.CompetitionuniqueID = competition.CompetitionuniqueID;
                    rawCompetition.Linkstatus = LinkEntityStatus.Original | LinkEntityStatus.Linked;
                    return rawCompetition;
                })
                .SetupFinally(rawCompetition => {
                    if (algoMode.HasFlag(GatherBehaviorMode.CreateNewLanguageName)) {
                        if (rawCompetition.CompetitionuniqueID != default(int) && !Competition.DataSource
                            .WhereEquals(Competition.Fields.CompetitionuniqueID, rawCompetition.CompetitionuniqueID)
                            .FilterByLanguage(language)
                            .IsExists()) {
                            new Competition {
                                CompetitionuniqueID = rawCompetition.CompetitionuniqueID,
                                Datecreatedutc = DateTime.UtcNow,
                                Gendertype = genderDetected,
                                SportType = sportType,
                                Name = CompetitionHelper.ListStringToName(nameOriginShort),
                                Languagetype = language
                            }.Save();
                        }
                    }
                    rawCompetition.Save();
                    return rawCompetition;
                })
                .MakeObject();

            return BrokerEntityIfaceCreator.CreateEntity<RawCompetitionSpecify>(brokerType, language, sportType, genderDetected, LinkEntityStatus.Unlinked, nameOrigin, specify => {
                specify.RawCompetitionID = competitionRaw.ID;
                if (specify.CompetitionuniqueID == default(int) && competitionRaw.CompetitionuniqueID != default(int)) {
                    specify.CompetitionuniqueID = competitionRaw.CompetitionuniqueID;
                }
            });
        }
Exemplo n.º 53
0
 public RawCompetitorSpecifyKey(BrokerType brokerType, LanguageType language, SportType sportType,
     GenderType genderDetected, string[] nameOrigin)
 {
     BrokerType = brokerType;
     Language = language;
     SportType = sportType;
     GenderDetected = genderDetected;
     NameOrigin = nameOrigin;
 }
Exemplo n.º 54
0
 public RawTemplateObj<CompetitionSpecifyTransport> GetCompetitionSpecify(ProcessStat competitionStat, ProcessStat competitionSpecifyStat, BrokerType brokerType, LanguageType language, SportType sportType, string[] nameOrigin, CompetitionParsed competitionToSave, GatherBehaviorMode algoMode)
 {
     return InvokeSafeSingleCall(() => {
         var genderDetected = GenderDetectorHelper.Instance[nameOrigin];
         if (genderDetected == GenderType.Unknown) {
             _logger.Error("{0}: {1}", nameOrigin, genderDetected);
         }
         nameOrigin = CleanCompetitionName(nameOrigin);
         var rawCompetitionSpecify = new BrokerEntityBuilder<RawCompetitionSpecify>(competitionSpecifyStat)
             .SetupValidateObject(specify => true/*NOTE!! && specify.CompetitionSpecifyUniqueID != default(int)*/)
             .SetupGetRaw(() => RawCompetitionHelper.GetRawCompetitionSpecify[new RawCompetitionHelper.RawCompetitorSpecifyKey(brokerType, language, sportType, genderDetected, nameOrigin)])
             .SetupCreateRaw(() => RawCompetitionHelper.CreateCompetitionSpecify(competitionStat, brokerType, language, sportType, genderDetected, nameOrigin, competitionToSave, algoMode))
             .SetupCreateOriginal(algoMode, specify => {
                 if (specify.CompetitionSpecifyUniqueID == default(int)) {
                     var competitionSpecifyUnique = new CompetitionSpecifyUnique {
                         CompetitionuniqueID = specify.CompetitionuniqueID
                     };
                     competitionSpecifyUnique.Save();
                     specify.CompetitionSpecifyUniqueID = competitionSpecifyUnique.ID;
                     specify.Save();
                 }
                 var competitionSpecify = new CompetitionSpecify {
                     Datecreatedutc = DateTime.UtcNow,
                     Languagetype = language,
                     SportType = sportType,
                     Name = CompetitionHelper.ListStringToName(nameOrigin),
                     Gendertype = genderDetected,
                     CompetitionuniqueID = specify.CompetitionuniqueID
                 };
                 specify.CompetitionSpecifyUniqueID = competitionSpecify.CompetitionSpecifyUniqueID;
                 if (competitionSpecify.CompetitionuniqueID != specify.CompetitionuniqueID) {
                     _logger.Error("{0} != {1}. {2}. SKIP", competitionSpecify.CompetitionuniqueID, specify.CompetitionuniqueID, CompetitionHelper.ListStringToName(nameOrigin));
                     return null;
                 }
                 specify.Linkstatus = LinkEntityStatus.Original | LinkEntityStatus.Linked;
                 return specify;
             })
             .SetupFinally(specify => {
                 if (specify.CompetitionSpecifyUniqueID != default(int)) {
                     if (algoMode.HasFlag(GatherBehaviorMode.CreateNewLanguageName)) {
                         if (specify.CompetitionSpecifyUniqueID != default(int) &&
                             specify.CompetitionuniqueID != default(int) && !CompetitionSpecify.DataSource
                                 .WhereEquals(CompetitionSpecify.Fields.CompetitionSpecifyUniqueID, specify.CompetitionSpecifyUniqueID)
                                 .FilterByLanguage(language)
                                 .IsExists()) {
                             new CompetitionSpecify {
                                 Languagetype = language,
                                 Name = CompetitionHelper.ListStringToName(nameOrigin),
                                 CompetitionSpecifyUniqueID = specify.CompetitionSpecifyUniqueID,
                                 CompetitionuniqueID = specify.CompetitionuniqueID,
                                 Datecreatedutc = DateTime.UtcNow,
                                 Gendertype = genderDetected,
                                 SportType = sportType
                             }.Save();
                         }
                     }
                 }
                 specify.Save();
                 return specify;
             })
             .MakeObject();
         return RawCompetitionHelper.CreateCompetitionSpecifyRawObject(rawCompetitionSpecify.ID, rawCompetitionSpecify.RawCompetitionID, rawCompetitionSpecify, language, sportType, genderDetected);
     }, new RawTemplateObj<CompetitionSpecifyTransport>());
 }
Exemplo n.º 55
0
 public MatchParsed(SportType sportType)
 {
     SportType = sportType;
     Odds = new List<OddParsed>();
 }
Exemplo n.º 56
0
        public static string[] GetShortCompetitionName(string[] names, SportType sportType)
        {
            var result = new List<string>();
            for (var i = 0; i < names.Length; i++) {
                var name = names[i];
                if (sportType != SportType.Tennis && _stopListWithGetNext.Any(slw => name.IndexOf(slw, StringComparison.InvariantCultureIgnoreCase) >= 0)) {
                    result.Add(name);
                    var nextIdx = i + 1;
                    if (nextIdx < names.Length) {
                        result.Add(names[nextIdx]);
                    }
                    break;
                }

                if (_stopListWithIncludeCurrent.Any(slw => name.IndexOf(slw, StringComparison.InvariantCultureIgnoreCase) >= 0)) {
                    result.Add(name);
                    break;
                }

                if (_stopListWithExcludeCurrent.Any(sl => name.IndexOf(sl, StringComparison.InvariantCultureIgnoreCase) >= 0) && result.Count > 0) {
                    break;
                }
                result.Add(name);
            }
            return result.ToArray();
        }
Exemplo n.º 57
0
 public RawTemplateObj<CompetitorParsedTransport> GetCompetitor(ProcessStat competitorStat, BrokerType brokerType, LanguageType languageType, SportType sportType, GenderType genderType, string[] names, GatherBehaviorMode algoMode)
 {
     return InvokeSafeSingleCall(() => {
         names = names
             .Where(name => !string.IsNullOrWhiteSpace(name))
             .Select(name => {
                 var indexOf = name.IndexOf("(", StringComparison.InvariantCultureIgnoreCase);
                 var cleanedName = (indexOf > 0 ? name.Substring(0, indexOf) : name).Trim(_trimChars);
                 return cleanedName.RemoveDiacritics();
             })
             .Where(name => !string.IsNullOrWhiteSpace(name))
             .ToArray();
         if (!names.Any()) {
             throw new Exception("nameFull.IsNullOrWhiteSpace() && nameShort.IsNullOrWhiteSpace()");
         }
         var competitors = new BrokerEntityBuilder<List<RawCompetitor>>(competitorStat)
             .SetupValidateObject(competitorsRaw => competitorsRaw.SafeAny() && competitorsRaw.All(c => c.CompetitoruniqueID != default(int)))
             .SetupGetRaw(() => RawCompetitorHelper.GetRawCompetitor[new RawCompetitorHelper.RawCompetitorCacheKey(brokerType, languageType, sportType, genderType, names)])
             .SetupCreateOriginal(algoMode, list => {
                 var uniqueID = new CompetitorUnique {
                     IsUsed = true
                 };
                 uniqueID.Save();
                 var competitor = new Competitor {
                     CompetitoruniqueID = uniqueID.ID,
                     SportType = sportType,
                     Datecreatedutc = DateTime.UtcNow,
                     Languagetype = languageType,
                     Name = names[0],
                     Gendertype = genderType
                 };
                 competitor.Save();
                 list.Each(el => el.Linkstatus = LinkEntityStatus.Original | LinkEntityStatus.Linked);
                 return list;
             })
             .SetupFinally(list => {
                 var firstElement = list.First();
                 if (algoMode.HasFlag(GatherBehaviorMode.CreateNewLanguageName) && firstElement.CompetitoruniqueID != default(int) && !Competitor.DataSource
                             .WhereEquals(Competitor.Fields.CompetitoruniqueID, firstElement.CompetitoruniqueID)
                             .WhereEquals(Competitor.Fields.Languagetype, (short)languageType)
                             .IsExists()) {
                     new Competitor {
                         CompetitoruniqueID = firstElement.CompetitoruniqueID,
                         SportType = sportType,
                         Datecreatedutc = DateTime.UtcNow,
                         Languagetype = languageType,
                         Name = names[0],
                         Gendertype = genderType
                     }.Save();
                 }
                 list.Each(el => el.Save());
                 return list;
             })
             .MakeObject();
         return competitors.Any()
             ? competitors.Select(c => new RawTemplateObj<CompetitorParsedTransport> {
                 RawObject = {
                     ID = c.ID
                 },
                 Object = {
                     LanguageType = languageType,
                     SportType = sportType,
                     GenderType = genderType,
                     ID = c.CompetitoruniqueID
                 }
             }).First()
             : new RawTemplateObj<CompetitorParsedTransport>();
     }, new RawTemplateObj<CompetitorParsedTransport>());
 }
Exemplo n.º 58
0
 public RawCompetitorCacheKey(BrokerType brokerType, LanguageType languageType, SportType sportType, GenderType genderType, string[] names)
 {
     BrokerType = brokerType;
     LanguageType = languageType;
     SportType = sportType;
     GenderType = genderType;
     Names = names;
 }
Exemplo n.º 59
0
 public CompetitionParsed(string[] competitionName, SportType sportType = SportType.Unknown)
 {
     Name = competitionName;
     Type = sportType != SportType.Unknown ? sportType : SportTypeHelper.Instance[competitionName];
     Matches = new List<MatchParsed>();
 }
Exemplo n.º 60
0
 public Activity(SportType sport, DateTime startTime, TimeSpan duration)
 {
     SportType = sport;
     StartTime = startTime;
     Duration = duration;
 }