Beispiel #1
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);
        }
Beispiel #2
0
        private static SsObjects.Fleet SelectExistingFleet(SsObjects.Club club)
        {
            var fleets = club.Fleets;
            Dictionary <int, SsObjects.Fleet> fleetDict = new
                                                          Dictionary <int, SsObjects.Fleet>();
            int i = 1;

            foreach (var fleet in fleets)
            {
                fleetDict.Add(i++, fleet);
            }
            foreach (var kvp in fleetDict)
            {
                Console.WriteLine($"{kvp.Key} - {kvp.Value.Name}");
            }
            int result = 0;

            while (result == 0)
            {
                Console.Write("Enter a number of a fleet from above > ");
                var input = Console.ReadLine();
                Int32.TryParse(input, out result);
            }

            return(fleetDict[result]);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        private static SsObjects.BoatClass SelectExistingBoatClass(SsObjects.Club club)
        {
            var boatClasses = club.BoatClasses;
            Dictionary <int, SsObjects.BoatClass> classDict = new
                                                              Dictionary <int, SsObjects.BoatClass>();
            int i = 1;

            foreach (var boatClass in boatClasses)
            {
                classDict.Add(i++, boatClass);
            }
            foreach (var kvp in classDict)
            {
                Console.WriteLine($"{kvp.Key} - {kvp.Value.Name}");
            }
            int result = 0;

            while (result == 0)
            {
                Console.Write("Enter a number of a class from above > ");
                var input = Console.ReadLine();
                Int32.TryParse(input, out result);
            }

            return(classDict[result]);
        }
Beispiel #5
0
        private SsObjects.BoatClass MakeNewBoatClass(SsObjects.Club club)
        {
            // Get Name and initials:
            Console.Write("Enter the new class name > ");
            var className = Console.ReadLine().Trim();

            SsObjects.BoatClass boatClass = new SsObjects.BoatClass
            {
                Id     = Guid.NewGuid(),
                Name   = className,
                ClubId = club.Id
            };

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

            return(boatClass);
        }
Beispiel #6
0
        private SsObjects.Club MakeNewClub()
        {
            // Get Name and initials:
            Console.Write("Enter the new club name > ");
            var clubName = Console.ReadLine().Trim();

            Console.Write("Enter the club initials > ");
            var clubInitials = Console.ReadLine().Trim();

            var club = new SsObjects.Club
            {
                Initials = clubInitials,
                Name     = clubName
            };

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

            return(club);
        }
Beispiel #7
0
        private static SsObjects.Series MakeSeries(SsObjects.Club club)
        {
            Console.Write("What is the name of this series? > ");
            var result = Console.ReadLine();

            SsObjects.Series ssSeries = new SsObjects.Series
            {
                ClubId = club.Id,
                Name   = result
            };
            return(ssSeries);
        }
Beispiel #8
0
        private SsObjects.Fleet GetFleet(SsObjects.Club club)
        {
            IList <SsObjects.Fleet> existingFleets = club.Fleets;

            if (existingFleets != null && existingFleets.Count != 0)
            {
                Console.WriteLine($"There are {existingFleets.Count} fleets already in this club.");
                Console.Write("Would you like to use one of those? (Y / N)");
                var result = Console.ReadLine();
                if (result.StartsWith("Y", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(SelectExistingFleet(club));
                }
            }
            return(MakeNewFleet(club));
        }
Beispiel #9
0
        private void SaveSeriesToClub(SwObjects.Series series, SsObjects.Club club)
        {
            var boatClass = GetBoatClass(club);
            var fleet     = GetFleet(club);
            int year      = GetYear();
            var ssSeries  = MakeSeries(club);

            ssSeries.Races = MakeRaces(series, club, boatClass, fleet, year);

            try
            {
                var createTask = _coreSeriesService.SaveNewSeries(ssSeries, club);
                createTask.Wait();
                //createTask.GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Oh Noes! There was an exception: {ex}");
            }
        }
Beispiel #10
0
 public void WriteSwSeriesToSS(SwObjects.Series series)
 {
     Console.WriteLine($"About to import a series with {series.Races.Count} race(s).");
     SsObjects.Club club = GetClub();
     SaveSeriesToClub(series, club);
 }