コード例 #1
0
        private SsObjects.Fleet MakeNewFleet(SsObjects.Club club)
        {
            // Get Name and initials:
            Console.Write("Enter the new Fleet full name > ");
            var fleetName = Console.ReadLine().Trim();

            Console.Write("Enter the new Fleet short name > ");
            var fleetShortName = Console.ReadLine().Trim();

            SsObjects.Fleet fleet = new SsObjects.Fleet
            {
                Id          = Guid.NewGuid(),
                Name        = fleetName,
                ShortName   = fleetShortName,
                ClubId      = club.Id,
                FleetType   = Api.Enumerations.FleetType.SelectedBoats,
                Competitors = new List <SsObjects.Competitor>()
            };

            try
            {
                var createTask = _coreClubService.SaveNewFleet(fleet);
                createTask.Wait();
                //createTask.GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Oh Noes! There was an exception: {ex}");
            }

            return(fleet);
        }
コード例 #2
0
        private static IList <SsObjects.Race> MakeRaces(
            SwObjects.Series series,
            SsObjects.Club club,
            SsObjects.BoatClass boatClass,
            SsObjects.Fleet fleet,
            int year)
        {
            var retList = new List <SsObjects.Race>();

            foreach (var swRace in series.Races)
            {
                DateTime date   = GetDate(swRace, year);
                int      rank   = GetRaceRank(swRace);
                var      ssRace = new SsObjects.Race
                {
                    Name   = swRace.Name,
                    Order  = rank,
                    ClubId = club.Id,
                    Date   = date,
                    Fleet  = fleet
                };
                ssRace.Scores = MakeScores(swRace, series.Competitors, boatClass, fleet);

                retList.Add(ssRace);
            }
            return(retList);
        }
コード例 #3
0
        private static IList <SsObjects.Score> MakeScores(
            SwObjects.Race swRace,
            IEnumerable <SwObjects.Competitor> swCompetitors,
            SsObjects.BoatClass boatClass,
            SsObjects.Fleet fleet)
        {
            var retList = new List <SsObjects.Score>();

            foreach (var swScore in swRace.Results)
            {
                if (String.IsNullOrWhiteSpace(swScore.Code) &&
                    swScore.Place == 0)
                {
                    continue;
                }
                // Not going to import DNCs.
                // Sailwave can leave DNC in some codes when type is changed to scored.
                if (swScore.Code == "DNC" && swScore.ResultType == 3)
                {
                    continue;
                }

                var ssScore = new SsObjects.Score
                {
                    Place = swScore.Place,
                    Code  = swScore.ResultType == 3 ? swScore.Code : null
                };
                var swCompetitor = swCompetitors.Single(c => c.Id == swScore.CompetitorId);
                ssScore.Competitor = new SsObjects.Competitor
                {
                    Name        = swCompetitor.HelmName,
                    SailNumber  = swCompetitor.SailNumber,
                    BoatName    = swCompetitor.Boat,
                    BoatClassId = boatClass.Id,
                    BoatClass   = boatClass
                };
                if (fleet.FleetType == Api.Enumerations.FleetType.SelectedBoats)
                {
                    if (ssScore.Competitor.Fleets == null)
                    {
                        ssScore.Competitor.Fleets = new List <SsObjects.Fleet>();
                    }
                    ssScore.Competitor.Fleets.Add(fleet);
                    fleet.Competitors.Add(ssScore.Competitor);
                }
                retList.Add(ssScore);
            }

            return(retList);
        }