private static ClubLocation CreateClubLocation(ClubLokaal location)
 {
     return(new ClubLocation
     {
         Id = location.Id,
         Description = location.Lokaal,
         Address = location.Adres,
         PostalCode = location.Postcode.ToString(),
         City = location.Gemeente,
         Mobile = location.Telefoon
     });
 }
        private async Task SyncClubLokalen(IEnumerable <ClubEntity> clubs, Func <ClubEntity, string> getClubCode)
        {
            foreach (var dbClub in clubs)
            {
                var oldLokalen = await _db.ClubLokalen.Where(x => x.ClubId == dbClub.Id).ToArrayAsync();

                var frenoyClubs = await _frenoy.GetClubsAsync(new GetClubs
                {
                    Club = getClubCode(dbClub)
                });

                var frenoyClub = frenoyClubs.GetClubsResponse.ClubEntries.FirstOrDefault();
                if (frenoyClub == null)
                {
                    Debug.Print("Got some wrong CodeSporta/Vttl in legacy db: " + dbClub.Naam);
                }
                else if (frenoyClub.VenueEntries == null)
                {
                    Debug.Print("Missing frenoy data?: " + dbClub.Naam);
                }
                else if (frenoyClub.VenueEntries.Length < dbClub.Lokalen.Count)
                {
                    Debug.Print("we got better data...: " + dbClub.Naam);
                }
                else
                {
                    _db.ClubLokalen.RemoveRange(oldLokalen);

                    foreach (var frenoyLokaal in frenoyClub.VenueEntries)
                    {
                        //Debug.Assert(string.IsNullOrWhiteSpace(frenoyLokaal.Comment), "comments opslaan in db?");
                        Debug.Assert(frenoyLokaal.ClubVenue == "1");
                        var lokaal = new ClubLokaal
                        {
                            Lokaal   = frenoyLokaal.Name,
                            Adres    = frenoyLokaal.Street,
                            ClubId   = dbClub.Id,
                            Gemeente = frenoyLokaal.Town.Substring(frenoyLokaal.Town.IndexOf(" ") + 1),
                            Telefoon = frenoyLokaal.Phone,
                            Postcode = int.Parse(frenoyLokaal.Town.Substring(0, frenoyLokaal.Town.IndexOf(" "))),
                            Hoofd    = frenoyLokaal.ClubVenue == "1" ? 1 : 0
                        };
                        _db.ClubLokalen.Add(lokaal);
                    }
                }
            }
            await _db.SaveChangesAsync();
        }
예제 #3
0
        private ClubEntity CreateClub(string frenoyClubCode)
        {
            Debug.Assert(_isVttl, "or need to write an if");
            var frenoyClub = _frenoy.GetClubs(new GetClubs
            {
                Club   = frenoyClubCode,
                Season = _options.FrenoySeason
            });

            Debug.Assert(frenoyClub.ClubEntries.Count() == 1);

            var club = new ClubEntity
            {
                CodeVttl = frenoyClubCode,
                Actief   = 1,
                Naam     = frenoyClub.ClubEntries.First().LongName,
                Douche   = 0
            };

            _db.Clubs.Add(club);
            CommitChanges();

            foreach (var frenoyLokaal in frenoyClub.ClubEntries.First().VenueEntries)
            {
                var lokaal = new ClubLokaal
                {
                    ClubId   = club.Id,
                    Telefoon = frenoyLokaal.Phone,
                    Lokaal   = frenoyLokaal.Name,
                    Adres    = frenoyLokaal.Street,
                    Postcode = int.Parse(frenoyLokaal.Town.Substring(0, frenoyLokaal.Town.IndexOf(" "))),
                    Gemeente = frenoyLokaal.Town.Substring(frenoyLokaal.Town.IndexOf(" ") + 1),
                    Hoofd    = 1
                };
                _db.ClubLokalen.Add(lokaal);
            }

            return(club);
        }
예제 #4
0
        private async Task <ClubEntity> CreateClub(string frenoyClubCode)
        {
            var frenoyClub = await _frenoy.GetClubsAsync(new GetClubs
            {
                Club   = frenoyClubCode,
                Season = _settings.FrenoySeason.ToString()
            });

            Debug.Assert(frenoyClub.GetClubsResponse.ClubEntries.Count() == 1);

            var club = new ClubEntity
            {
                CodeVttl   = _isVttl ? frenoyClubCode : null,
                CodeSporta = !_isVttl ? frenoyClubCode : null,
                Actief     = 1,
                Naam       = frenoyClub.GetClubsResponse.ClubEntries.First().LongName,
                Douche     = 0
            };

            _db.Clubs.Add(club);
            await CommitChanges();

            foreach (var frenoyLokaal in frenoyClub.GetClubsResponse.ClubEntries.First().VenueEntries)
            {
                var lokaal = new ClubLokaal
                {
                    ClubId   = club.Id,
                    Telefoon = frenoyLokaal.Phone,
                    Lokaal   = frenoyLokaal.Name,
                    Adres    = frenoyLokaal.Street,
                    Postcode = int.Parse(frenoyLokaal.Town.Substring(0, frenoyLokaal.Town.IndexOf(" "))),
                    Gemeente = frenoyLokaal.Town.Substring(frenoyLokaal.Town.IndexOf(" ") + 1),
                    Hoofd    = 1
                };
                _db.ClubLokalen.Add(lokaal);
            }

            return(club);
        }
예제 #5
0
        private ClubEntity CreateClub(string frenoyClubCode)
        {
            Debug.Assert(_isVttl, "or need to write an if");
            var frenoyClub = _frenoy.GetClubs(new GetClubs
            {
                Club = frenoyClubCode,
                Season = _options.FrenoySeason
            });
            Debug.Assert(frenoyClub.ClubEntries.Count() == 1);

            var club = new ClubEntity
            {
                CodeVttl = frenoyClubCode,
                Actief = 1,
                Naam = frenoyClub.ClubEntries.First().LongName,
                Douche = 0
            };
            _db.Clubs.Add(club);
            CommitChanges();

            foreach (var frenoyLokaal in frenoyClub.ClubEntries.First().VenueEntries)
            {
                var lokaal = new ClubLokaal
                {
                    ClubId = club.Id,
                    Telefoon = frenoyLokaal.Phone,
                    Lokaal = frenoyLokaal.Name,
                    Adres = frenoyLokaal.Street,
                    Postcode = int.Parse(frenoyLokaal.Town.Substring(0, frenoyLokaal.Town.IndexOf(" "))),
                    Gemeente = frenoyLokaal.Town.Substring(frenoyLokaal.Town.IndexOf(" ") + 1),
                    Hoofd = 1
                };
                _db.ClubLokalen.Add(lokaal);
            }

            return club;
        }