Exemple #1
0
        public ActionResult Competition(long id)
        {
            S_Challenge challenge = ChallengeManager.GetChallenge(id);

            ObservableCollection <CompetitionGridModel> competitionModelList = new ObservableCollection <CompetitionGridModel>();

            List <S_Competition> competitionList;

            competitionList = CompetitionManager.GetCompetitionsByChallengeId(id);

            foreach (S_Competition competition in competitionList)
            {
                CompetitionGridModel cgm = new CompetitionGridModel();
                cgm.Id          = competition.id;
                cgm.challenge   = challenge.name;
                cgm.challengeId = id;
                cgm.description = competition.description;
                cgm.EndDate     = competition.enddate;
                cgm.Id          = competition.id;
                cgm.price       = competition.price;
                cgm.StartDate   = competition.startdate;

                competitionModelList.Add(cgm);
            }

            ViewBag.challengeid = id;

            return(View(competitionModelList));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.MaintainScrollPositionOnPostBack = true;

            if (!this.IsPostBack)
            {
                List <S_Competition> competitions = CompetitionManager.GetRunningCompetitions(true);

                ListItem item = new ListItem();
                item.Value = "0";
                item.Text  = "-- Selecteer een competitie --";
                compCompetitie.Items.Add(item);

                foreach (S_Competition competition in competitions)
                {
                    S_Challenge challenge = ChallengeManager.GetChallenge(competition.challengeid);

                    item       = new ListItem();
                    item.Value = competition.id.ToString();
                    item.Text  = Conversion.DateToTitle(competition.startdate, competition.enddate) + " : " + challenge.name;
                    compCompetitie.Items.Add(item);
                }

                bool auth = Convert.ToBoolean(Session["auth"]);

                if (auth)
                {
                    long   id   = Convert.ToInt64(Session["uid"]);
                    S_User user = UserManager.GetUserById(id);
                    compFrequentBowlerNaam.Text   = user.username;
                    compFrequentBowlerNummer.Text = user.frequentbowlernumber.ToString();
                }
            }
        }
Exemple #3
0
        private void buildCompetitions(S_User user)
        {
            List <S_Competition> competitions = CompetitionManager.GetCompetitionsByPlayer(user.id);


            _competitions  = "<div class='col-lg-8 col-lg-offset-2'>";
            _competitions += "  <h2>Jouw Competities</h2>";
            if (competitions.Count() > 0)
            {
                foreach (S_Competition competition in competitions)
                {
                    S_Challenge challenge = ChallengeManager.GetChallenge(competition.challengeid);
                    List <S_CompetitonBowlingcenter> competitonBowlingcenters = CompetitionManager.GetBowlingcentersByCompetition(competition.id);

                    _competitions += "  <h3>" + challenge.name + "</h3>";
                    _competitions += " <p> Van " + competition.startdate.ToString("dd-MM-yyyy") + " tot " + competition.enddate.ToString("dd-MM-yyyy") + " bij de volgende bowlingcentra: ";

                    foreach (S_CompetitonBowlingcenter competitonBowlingcenter in competitonBowlingcenters)
                    {
                        S_BowlingCenter bowlingCenter = BowlingCenterManager.GetBowlingCenterById(competitonBowlingcenter.bowlingcenterid);
                        _competitions += "<br/><br/>" + bowlingCenter.name;
                    }

                    _competitions += "</p>";
                }
            }
            else
            {
                _competitions += "  <p>Je doet nog niet mee aan een competitie</p>";
            }
            _competitions += "</div>";
        }
        private static S_Challenge DataToChallengeObject(MySqlDataReader dataReader)
        {
            S_Challenge challenge = new S_Challenge();

            challenge.id   = Conversion.SqlToLongOrNull(dataReader["id"]).Value;
            challenge.name = Conversion.SqlToString(dataReader["name"]);

            return(challenge);
        }
Exemple #5
0
        public ActionResult Insert(long id)
        {
            S_Challenge      s = ChallengeManager.GetChallenge(id);
            CompetitionModel m = new CompetitionModel();

            m.challengeId = id;
            m.challenge   = s.name;

            return(View(m));
        }
        public static S_Challenge GetChallengeByCompetition(long id)
        {
            S_Challenge challenge = null;

            try
            {
                DatabaseConnection databaseconnection = new DatabaseConnection();

                //Open connection
                if (databaseconnection.OpenConnection())
                {
                    //Create Command
                    MySqlCommand command = new MySqlCommand();
                    command.Connection  = databaseconnection.getConnection();
                    command.CommandText = "SELECT ch.* FROM challenge ch, competition co WHERE ch.id = co.challengeid AND co.id=@id";
                    command.Parameters.AddWithValue("@id", Conversion.LongToSql(id));

                    //Create a data reader and Execute the command
                    MySqlDataReader dataReader = command.ExecuteReader();

                    //Read the data and store them in the list
                    if (dataReader.Read())
                    {
                        challenge = DataToChallengeObject(dataReader);
                    }

                    //close Data Reader
                    dataReader.Close();

                    //close Connection
                    databaseconnection.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("GetChallenge, Error reading challenge data: {0}", ex.Message));
            }

            return(challenge);
        }
Exemple #7
0
        public ActionResult competitionranking(long id, string name, long challengeid)
        {
            ObservableCollection <PlayerRankingGridModel> playerRankingModelList         = new ObservableCollection <PlayerRankingGridModel>();
            ObservableCollection <PlayerRankingGridModel> filteredPlayerRankingModelList = new ObservableCollection <PlayerRankingGridModel>();

            List <S_CompetitionPlayers> playerList;

            playerList = CompetitionManager.GetPlayersByCompetition(id);

            if (playerList != null && playerList.Count() > 0)
            {
                S_Competition competition = CompetitionManager.GetCompetition(playerList[0].competitionid);
                S_Challenge   challenge   = ChallengeManager.GetChallengeByCompetition(playerList[0].competitionid);
                List <S_CompetitionPlayersRanking> cprl = CompetitionManager.GetCompetitionPlayersRanking(challenge.id, playerList[0].competitionid, playerList, competition.startdate, competition.enddate);

                foreach (S_CompetitionPlayersRanking cpr in cprl)
                {
                    PlayerRankingGridModel prgm = new PlayerRankingGridModel();
                    prgm.Rank   = cpr.Rank;
                    prgm.UserId = cpr.UserId;
                    prgm.Name   = cpr.Name;
                    prgm.FrequentBowlernumber = cpr.FrequentBowlernumber;
                    prgm.Score = cpr.Score;

                    playerRankingModelList.Add(prgm);
                }

                int rank = cprl.Count();
                if (challengeid != 6)
                {
                    foreach (S_CompetitionPlayers cp in playerList)
                    {
                        bool playerInRanking = false;
                        foreach (PlayerRankingGridModel prgm in playerRankingModelList)
                        {
                            if (prgm.UserId == cp.userid)
                            {
                                playerInRanking = true;
                            }
                        }
                        if (!playerInRanking)
                        {
                            S_User u = UserManager.GetUserById(cp.userid);
                            playerRankingModelList.Add(new PlayerRankingGridModel {
                                Name = u.name, FrequentBowlernumber = u.frequentbowlernumber, Rank = ++rank
                            });
                        }
                    }
                }

                foreach (PlayerRankingGridModel prgm in playerRankingModelList)
                {
                    if (name == null || prgm.Name.ToUpper().Contains(name.ToUpper()))
                    {
                        filteredPlayerRankingModelList.Add(prgm);
                    }
                }
            }

            ViewBag.competitionid = id;
            ViewBag.challengeid   = challengeid;

            return(View(filteredPlayerRankingModelList));
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.MaintainScrollPositionOnPostBack = true;

            bool auth = Convert.ToBoolean(Session["auth"]);

            if (!auth)
            {
                _login_out = "<a class='portfolio-link' href='./Login.aspx' id='login'>Login</a>";
                _account   = "";
            }
            else
            {
                _login_out = "<a class='portfolio-link' href='./Logout.aspx' id='login'>Logout</a>";
                _account   = "<a class='portfolio-link' href='./Profile.aspx' id='profile'>Profiel</a>";
            }

            List <S_Text> texts = TextManager.GetTexts();

            foreach (S_Text st in texts)
            {
                switch (st.label)
                {
                case "Web Site Titel":
                    web_site_title.Text = st.text;
                    break;

                case "Home":
                    home.Text = st.text;
                    break;

                case "Meld je aan":
                    meldjeaan.Text = st.text;
                    break;

                case "Installeer de app":
                    installeerdeapp.Text = st.text;
                    break;

                case "Ga bowlen":
                    gabowlen.Text = st.text;
                    break;
                }
            }

            if (!this.IsPostBack)
            {
                List <S_Competition> competitions = CompetitionManager.GetRunningCompetitions(true);

                int cntr = 0;
                foreach (S_Competition competition in competitions)
                {
                    S_Challenge challenge = ChallengeManager.GetChallenge(competition.challengeid);

                    string style = "";
                    if (cntr % 2 == 0)
                    {
                        style = "class='timeline-inverted'";
                    }

                    _content += "<li " + style + " > " +
                                "<div class='timeline-image'> " +
                                "     <img class='img-circle img-responsive' src='img/competities/1.png' alt=''> " +
                                " </div> " +
                                " <div class='timeline-panel'> " +
                                "     <div class='timeline-heading'> " +
                                "         <h4>" + challenge.name + "</h4> " +
                                "         <h4 class='subheading'>" + Conversion.DateToTitle(competition.startdate, competition.enddate) + "</h4> " +
                                "     </div> " +
                                "     <div class='timeline-body'> " +
                                "         <p class='text-muted'>" + competition.description + " <a href='./Competitie.aspx' class='portfolio-link'>Doe mee!</a></p> " +
                                "     </div> " +
                                " </div> " +
                                "</li> ";

                    cntr++;
                }

                long fbn = generateFrequentBowlerNumber();
                int  cnt = 0;
                while (UserManager.UserExistByFrequentBowlerNumber(fbn) && cnt++ < 10)
                {
                    fbn = generateFrequentBowlerNumber();
                }
                meldfrequentbowlernummmer.Text = fbn.ToString();
            }
        }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.MaintainScrollPositionOnPostBack = true;

            if (!this.IsPostBack)
            {
                List <S_Competition> competitions = CompetitionManager.GetCompetitions(true);

                //ListItem item = new ListItem();
                //item.Value = "0";
                //item.Text = "-- Selecteer een competitie --";
                //compCompetitie.Items.Add(item);

                foreach (S_Competition competition in competitions)
                {
                    S_Challenge challenge = ChallengeManager.GetChallenge(competition.challengeid);

                    //item = new ListItem();
                    //item.Value = competition.id.ToString();
                    //item.Text = Conversion.DateToTitle(competition.startdate, competition.enddate) + " : " + challenge.email;
                    //compCompetitie.Items.Add(item);

                    List <S_CompetitionPlayers> playerList;
                    playerList = CompetitionManager.GetPlayersByCompetition(competition.id);

                    if (playerList != null && playerList.Count() > 0)
                    {
                        challenge = ChallengeManager.GetChallengeByCompetition(playerList[0].competitionid);
                        List <S_CompetitionPlayersRanking> cprl = CompetitionManager.GetCompetitionPlayersRanking(challenge.id, playerList[0].competitionid, playerList, competition.startdate, competition.enddate);

                        List <S_CompetitionPlayersRanking> playerRankingModelList = new List <S_CompetitionPlayersRanking>();
                        foreach (S_CompetitionPlayersRanking c in cprl)
                        {
                            playerRankingModelList.Add(c);
                        }


                        int rank = playerRankingModelList.Count();
                        if (challenge.id != 6)
                        {
                            foreach (S_CompetitionPlayers cp in playerList)
                            {
                                bool playerInRanking = false;
                                foreach (S_CompetitionPlayersRanking c in cprl)
                                {
                                    if (c.UserId == cp.userid)
                                    {
                                        playerInRanking = true;
                                    }
                                }
                                if (!playerInRanking)
                                {
                                    S_User u = UserManager.GetUserById(cp.userid);
                                    playerRankingModelList.Add(new S_CompetitionPlayersRanking {
                                        Name = u.name, FrequentBowlernumber = u.frequentbowlernumber, Rank = ++rank
                                    });
                                }
                            }
                        }

                        _content += "<br/><br/><h4>" + Conversion.DateToTitle(competition.startdate, competition.enddate) + " : " + challenge.name + "</h4>";
                        _content += "<table width='100%'>";
                        int row = 0;
                        foreach (S_CompetitionPlayersRanking s in playerRankingModelList)
                        {
                            string background = "lightgrey";
                            if (row++ % 2 == 0)
                            {
                                background = "white";
                            }
                            _content += "<tr><td width='20px' style='background-color:" + background + ";text-align:left;border-bottom: 1px solid black'>" + s.Rank + "</td><td width='120px' style='background-color:" + background + ";text-align:left;border-bottom: 1px solid black'>" + s.Name + "</td><td width='30px' style='background-color:" + background + ";text-align:left;border-bottom: 1px solid black'>" + s.Score + "</td></tr>";
                        }
                        _content += "</table>";
                    }
                }
            }
        }