Esempio n. 1
0
        /// <inheritdoc/>
        public void Organisers(ICaller caller)
        {
            using IDealData data = InstanceFactory.GetInstance <IDealData>();

            IList <IOrganiser> existingOrganisers = data.ReadAllOrganisers();

            IDictionary <string, string> organiserDetails = new Dictionary <string, string>
            {
                { "LCBA", "LCBA" },
                { "CBC", "County Bridge Club" },
                { "BRADGATE", "Bradgate Bridge Club" },
                { "GLENFIELD", "Glenfield Bridge Club" },
                { "CBT", "Charnwood Bridge Teachers" }
            };

            foreach (KeyValuePair <string, string> organiserDetail in organiserDetails)
            {
                if (existingOrganisers.Any(o => o.Code == organiserDetail.Key))
                {
                    continue;
                }

                IOrganiser organiser = new Organiser(
                    id: Guid.NewGuid(),
                    code: organiserDetail.Key,
                    name: organiserDetail.Value);

                data.CreateOrganiser(organiser);
                Console.WriteLine($@"Seeding Dealer: {organiser.Name}.");
            }
        }
Esempio n. 2
0
        /// <inheritdoc />
        public void Seasons(ICaller caller)
        {
            using IDealData data = InstanceFactory.GetInstance <IDealData>();

            IList <ISeason> existingSeasons = data.ReadAllSeasons();

            IList <IOrganiser> existingOrganisers = data.ReadAllOrganisers();

            IList <ISeason> seasons = new List <ISeason>
            {
                new Season(
                    id: Guid.NewGuid(),
                    organiser: existingOrganisers.Single(o => o.Code == "BRADGATE"),
                    description: "2019/20",
                    startDate: new DateTime(2019, 11, 01),
                    endDate: new DateTime(2020, 10, 31)),
                new Season(
                    id: Guid.NewGuid(),
                    organiser: existingOrganisers.Single(o => o.Code == "GLENFIELD"),
                    description: "2019/20",
                    startDate: new DateTime(2019, 05, 23),
                    endDate: new DateTime(2020, 05, 20)),
                new Season(
                    id: Guid.NewGuid(),
                    organiser: existingOrganisers.Single(o => o.Code == "CBC"),
                    description: "2019/20",
                    startDate: new DateTime(2019, 06, 01),
                    endDate: new DateTime(2020, 05, 31)),
                new Season(
                    id: Guid.NewGuid(),
                    organiser: existingOrganisers.Single(o => o.Code == "CBT"),
                    description: "2019/20",
                    startDate: new DateTime(2019, 06, 01),
                    endDate: new DateTime(2020, 05, 31)),
                new Season(
                    id: Guid.NewGuid(),
                    organiser: existingOrganisers.Single(o => o.Code == "LCBA"),
                    description: "2019/20",
                    startDate: new DateTime(2019, 06, 01),
                    endDate: new DateTime(2020, 05, 31))
            };

            foreach (ISeason season in seasons)
            {
                ISeason existingSeason = existingSeasons
                                         .Where(es => es.Organiser.Code == season.Organiser.Code)
                                         .SingleOrDefault(es => es.Description == season.Description);

                if (existingSeason == null)
                {
                    data.CreateSeason(season);
                    Console.WriteLine($@"Seeding Season: {season.Organiser.Code} {season.Description}.");
                }
                else
                {
                    if (existingSeason.StartDate == season.StartDate &&
                        existingSeason.EndDate == season.EndDate)
                    {
                        continue;
                    }

                    existingSeason.SetDates(season.StartDate, season.EndDate);
                    data.UpdateSeason(existingSeason);

                    Console.WriteLine($@"Updating Season: {season.Organiser.Code} {season.Description}.");
                }
            }
        }