コード例 #1
0
        public static void ProcessClubData(OdbcDataReader reader)
        {
            logger.Info("Started Processing Club Details");
            while (reader.Read())
            {
                ClubEntity club = new ClubEntity();
                club.ClubCode = reader["Team_abbr"].ToString();
                club.ClubName = reader["Team_name"].ToString();

                try
                {
                    ClubRepo.AddClub(club);
                }
                catch (Exception e)
                {
                    if (e.Message.Contains("Violation of PRIMARY KEY constraint"))
                    {
                        logger.Info("Duplicate:" + club.ClubCode);
                    }
                }

                finally { }
            }
            logger.Info("Processing Club Details Completed");
        }
コード例 #2
0
 private static void MapClub(Club club, ClubEntity existingClub)
 {
     existingClub.Naam    = club.Name;
     existingClub.Douche  = club.Shower ? 1 : 0;
     existingClub.Website = club.Website;
     // existingClub.Lokalen = club.MainLocation
 }
コード例 #3
0
        public static ClubEntity GetClub(String ClubCode)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["AODB"].ConnectionString);
            string        selectStatement
                = "SELECT * "

                  + "FROM Clubs "
                  + "WHERE ClubCode = @Code";
            SqlCommand selectCommand =
                new SqlCommand(selectStatement, connection);

            selectCommand.Parameters.AddWithValue(
                "@Code", ClubCode);
            try
            {
                connection.Open();
                SqlDataReader proReader =
                    selectCommand.ExecuteReader(
                        System.Data.CommandBehavior.SingleRow);
                if (proReader.Read())
                {
                    ClubEntity club = new ClubEntity();
                    club.ClubCode = proReader["ClubCode"].ToString();
                    club.ClubName = proReader["ClubName"].ToString();

                    return(club);
                }
                else
                {
                    return(null);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
        public static int AddClub(ClubEntity club)
        {
            SqlConnection connection      = new SqlConnection(ConfigurationManager.ConnectionStrings["AODB"].ConnectionString);
            string        insertStatement =
                "INSERT into Clubs " +
                "(ClubCode,ClubName) " +
                "VALUES (@ClubCode,@ClubName)";
            SqlCommand insertCommand =
                new SqlCommand(insertStatement, connection);

            insertCommand.Parameters.AddWithValue(
                "@ClubCode", club.ClubCode);
            insertCommand.Parameters.AddWithValue(
                "@ClubName", club.ClubName);



            try
            {
                connection.Open();
                int value = insertCommand.ExecuteNonQuery();
                return(value);
            }
            catch (SqlException ex)
            {
                if (ex.Message.Contains("Violation of PRIMARY KEY constraint"))
                {
                    logger.Error("Duplicate:" + club.ClubCode);
                }
                return(0);
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #7
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;
        }
コード例 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var schoolId = int.Parse(Request.Cookies["SmacCookie"]["SchoolId"]);
            var userId   = Request.Cookies["SmacCookie"]["UserId"];

            if (!IsPostBack)
            {
                var clubs   = ClubEntity.GetAllClubs(schoolId);
                var myClubs = ClubEntity.GetMyClubs(schoolId, userId);
                if (myClubs.Count > 0)
                {
                    string myClubList = string.Empty;

                    foreach (var club in myClubs)
                    {
                        myClubList += club.ClubId + ";";
                    }

                    this.myClubNames.Value = myClubList.Substring(0, myClubList.LastIndexOf(";"));
                }

                var clubObj = new object[clubs.Count];

                for (int i = 0; i < clubs.Count; ++i)
                {
                    var scheds = ClubScheduleEntity.GetClubSchedule(clubs[i].ClubId);

                    scheds.Sort(new DayOfWeekComparer());

                    var schdObj = new object[scheds.Count];

                    for (int j = 0; j < scheds.Count; ++j)
                    {
                        var scheduleObj = new
                        {
                            day   = scheds[j].Day,
                            times = Helpers.NormalizeTimespanString(scheds[j].TimeSpans)
                        };

                        schdObj[j] = scheduleObj;
                    }

                    var Cobj = new
                    {
                        id       = clubs[i].ClubId,
                        name     = clubs[i].ClubName,
                        desc     = clubs[i].Description,
                        schedule = schdObj
                    };

                    clubObj[i] = Cobj;
                }

                this.clubScheduleHdn.Value = JsonConvert.SerializeObject(clubObj);

                var list = new List <string> {
                    "ClubId", "ClubName", "ClubDesc"
                };

                DataTable table = new DataTable();

                foreach (var item in list)
                {
                    table.Columns.Add(item, typeof(string));
                }

                //Now add some rows(which will be repeated in the ItemTemplate)
                foreach (var club in clubs)
                {
                    table.Rows.Add(club.ClubId.ToString(), club.ClubName, club.Description);
                }

                clubListView.DataSource = table;
                clubListView.DataBind();
            }
        }