Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string match_id = Request.QueryString[0];

            Matches match = new Matches();

            string[] matchInfo = match.getMatchInfo(match_id);

            string date = matchInfo[1].Substring(0, matchInfo[1].IndexOf(" ") + 1);

            string time = matchInfo[1].Substring(matchInfo[1].IndexOf(" "));
            string ampm = matchInfo[1][matchInfo[1].Length - 2].ToString() + matchInfo[1][matchInfo[1].Length - 1].ToString();

            // == MATCHINFO ARRAY : ==
            //0 = NAME //1 = DATE
            //2 = TYPE //3 = FIELD

            Mname.InnerText = matchInfo[0];
            Mdate.InnerText = date;
            Mtime.InnerText = time.Substring(0, time.LastIndexOf(" ") - 3) + " " + ampm;


            string domain = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/";
            string src    = domain + "upMatchIframe?match_id=" + match_id;
            string href   = domain + "MatchRoom?match_id=" + match_id;
        }
Beispiel #2
0
        }// AS A CAPTAIN

        public List <Matches> getPlayerJoinedMatches(string uid)// AS A PLAYER NOT ENDED
        {
            List <Matches> joinedMatches = new List <Matches>();

            string queryString = "SELECT matchesPlayers_matchesId " +
                                 "FROM matchesPlayers " +
                                 "INNER JOIN users " +
                                 "ON matchesPlayers_userId = users.user_id " +
                                 "INNER JOIN matches " +
                                 "ON matchesPlayers_matchesId = matches.match_id " +
                                 "WHERE users.user_id=@uid AND matches.match_date > GETDATE()";

            //string queryString = "SELECT matchesPlayers_matchesId FROM matchesPlayers INNER JOIN users ON matchesPlayers_userId = users.user_id INNER JOIN matches ON matchesPlayers_matchesId = matches.match_id WHERE users.user_id=@uid AND matches.match_date > GETDATE()";

            using (SqlConnection connection = new SqlConnection(cs))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                try
                {
                    command.Connection.Open();
                    command.Parameters.AddWithValue("@uid", uid);

                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        Matches match = new Matches();

                        match.id   = reader[0].ToString();
                        match.name = match.getMatchInfo(reader[0].ToString())[0];



                        joinedMatches.Add(match);
                    }
                }
                catch (SqlException ex)
                {
                    for (int i = 0; i < ex.Errors.Count; i++)
                    {
                        errorMessages.Append("Index #" + i + "\n" +
                                             "Message: " + ex.Errors[i].Message + "\n" +
                                             "LineNumber: " + ex.Errors[i].LineNumber + "\n" +
                                             "Source: " + ex.Errors[i].Source + "\n" +
                                             "Procedure: " + ex.Errors[i].Procedure + "\n");
                    }

                    Matches error = new Matches();
                    Console.WriteLine(errorMessages.ToString());
                    error.name = errorMessages.ToString();
                }
            }



            return(joinedMatches);
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string match_id = Request.QueryString[0];


            // === M A T C H ===
            Matches match = new Matches();

            string[] matchInfo = match.getMatchInfo(match_id);


            // == MATCHINFO ARRAY : ==
            //0 = NAME //1 = CITY //2 = DATE //3 = TYPE //4 = FIELD

            // === /M A T C H



            // === C O U R T ===
            Courts court = new Courts();

            string[]      courtInfo = court.getCourtInfo(Int32.Parse(matchInfo[3]));
            List <String> courtImgs = court.getCourtImages(Int32.Parse(matchInfo[3]));
            string        url       = "https://www.google.com/maps/embed/v1/place?key=AIzaSyDT-7W1RK56peUVp3CRTKxuQ5pyoifLnH8&q="
                                      + courtInfo[3] + "," + courtInfo[4] + "&zoom=12";

            string iframeUrl = "<iframe width=\"210\" height=\"160\" src=\"" + url
                               + "\"   frameborder=\"0\" style=\"border: 0\" > </iframe>";

            // == COURTINFO ARRAY : ==
            //0 = NAME //1 = CITY //2 = LIMIT //3 = LAT //4 = LNG


            // === /C O U R T ===



            // === FILLING DATA ====


            // Match related info
            Mname.InnerText     = matchInfo[0];
            Mcity.InnerText     = courtInfo[1];
            Mdatetime.InnerText = matchInfo[1];

            // Court related info
            fillSrc(courtImgs);
            Cname.InnerText     = courtInfo[0];
            Clocation.InnerHtml = iframeUrl;

            //viewMatch.Attributes["href"] = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + "MatchRoom?match_id=" + match_id;
        }
        public void createBlockStructure(string id, int i)
        {
            Matches match = new Matches();

            string[] matchInfo = match.getMatchInfo(id);

            if (matchInfo[2] == "Public")
            {
                string domain    = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/";
                string src       = domain + "UpcomingBlock?match_id=" + id;
                string iframeTag = " <iframe id='iframe" + i + "' src='" + src + "' frameborder='0' style='width:100%;' class='minus-margin'></iframe>";

                upmatchBlock.InnerHtml += iframeTag;
            }
        }
        protected void GoPublic_Click(object sender, EventArgs e)
        {
            Matches match = new Matches();

            match.toggleMatchType(match_id, "Public");

            string[] matchInfo = match.getMatchInfo(match_id);
            //"MatchRoom.aspx?match_id=" + $(element).attr("id") + "&type=Public";
            if (matchInfo[2] == "Public")
            {
                Response.Redirect("~/MatchRoom.aspx?match_id=" + match_id + "&type=Public");
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }
Beispiel #6
0
        public bool IsTeamFull(string mid, int team)
        {
            Matches match = new Matches();

            string[] matchInfo = match.getMatchInfo(mid);

            List <string> teamList = this.getTeam(mid, team);
            Courts        court    = new Courts();

            string[] courtInfo = court.getCourtInfo(Int32.Parse(matchInfo[3]));

            string courtLimit = courtInfo[2];
            int    teamLimit  = Int32.Parse(courtInfo[2]) / 2;

            if (teamList.Count() == teamLimit)
            {// team is full
                return(true);
            }

            return(false);
        }
        public void checkIfFull()
        {
            Matches match = new Matches();

            string[] matchInfo = match.getMatchInfo(match_id);
            Courts   court     = new Courts();

            string[] courtInfo = court.getCourtInfo(Int32.Parse(matchInfo[3]));

            string courtLimit = courtInfo[2];
            int    teamLimit  = Int32.Parse(courtInfo[2]) / 2;


            // Check if team A is full:
            List <string> teamA = match.getTeam(match_id, 1);

            if (teamA.Count() == teamLimit)   // team A is full
            {
                if (!teamA.Contains(user_id)) // if not current user:
                {
                    JoinA.Visible     = false;
                    teamAfull.Visible = true;
                }
            }

            // Check if team B is full:
            List <string> teamB = match.getTeam(match_id, 2);

            if (teamB.Count() == teamLimit)   // team B is full
            {
                if (!teamB.Contains(user_id)) // if not current user:
                {
                    JoinB.Visible     = false;
                    teamBfull.Visible = true;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] == null || Session["userid"] == null)
            {
                Response.Redirect("~/Login.aspx");
            }

            else//Session is available
            {
                // Get user ID from session, match ID from URL query string
                user_id  = Session["userid"].ToString();
                match_id = Request.QueryString.Get(0);
            }

            Matches match = new Matches();

            string[] MatchInfo = match.getMatchInfo(match_id);

            Courts court = new Courts();

            string[] courtInfo = court.getCourtInfo(Int32.Parse(MatchInfo[3]));

            type = MatchInfo[2];

            if (type == "Private" && isCaptain(user_id, match_id))// if private and captain
            {
                pvt.Visible = true;
            }
            if (type == "Public" && isCaptain(user_id, match_id))// if private and captain
            {
                pvt1.Visible = true;
            }
            if (type == "Public")
            {
                status.Visible             = true;
                status.InnerText           = "public.";
                status.Attributes["class"] = "subtitle-pub";
            }
            if (type == "Private")
            {
                status.Visible             = true;
                status.InnerText           = "private.";
                status.Attributes["class"] = "subtitle-pvt";
            }



            List <String> courtImgs = court.getCourtImages(Int32.Parse(MatchInfo[3]));

            string courtLocationUrl = "https://maps.google.com/?q=";

            string lat = courtInfo[3];
            string lng = courtInfo[4];

            courtLocationUrl += lat + "," + lng + "&ll=" + lat + "," + lng + "&z=15";

            // == Filling data: ==

            if (!IsPostBack)
            {
                checkIfFull();
                checkIfJoined(user_id, match_id);
                fillDefaultSlots(Int32.Parse(MatchInfo[3]));
                fillSlotsTeam1(match_id);
                fillSlotsTeam2(match_id);
                fillCourtImages(courtImgs);
            }

            matchName.InnerText = MatchInfo[0];
            matchDate.InnerText = MatchInfo[1];

            courtName.InnerText = courtInfo[0];
            matchCity.InnerText = courtInfo[1];
            courtLocation.HRef  = courtLocationUrl;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            userid = Request.QueryString["userid"].ToString();

            Users user = new Users();

            List <string[]> requested = user.getRequestedList(userid, 0);


            if (requested != null)
            {
                for (int i = 0; i < requested.Count(); i++)
                {
                    string reqid    = requested[i][0];
                    string username = requested[i][1];

                    string friendReqBlock = "<div runat='server' style='font-size: 12.5px;' class='py-1 my-1'>Friend request</div> " +
                                            "<div class='row notif-row my-2'> " +
                                            "<div runat='server'>" + username + "#" + reqid + "</div> " +
                                            "<div id='" + reqid + "' class='btn btn-sm btn-info p-1 m-1' onclick='accepted(this); return true;'>Accept</div> " +
                                            "<div id='" + reqid + "' class='btn btn-sm btn-warning p-1 m-1' onclick='decline(this); return true;'>Decline</div> " +
                                            "</div>";


                    notif.InnerHtml += friendReqBlock;
                }
            }

            //MATCH INVITES

            List <string[]> invited = user.getMatchInvites(userid);

            //test.InnerText = invited[0][0];


            if (invited != null)
            {
                for (int i = 0; i < invited.Count(); i++)
                {
                    string matchid  = invited[i][0];
                    string senderid = invited[i][1];
                    string read     = invited[i][2];

                    Matches  match     = new Matches();
                    string   code      = match.getPvtMatchCode(matchid);
                    string[] matchinfo = match.getMatchInfo(matchid);
                    string   type      = matchinfo[2];
                    // == MATCHINFO ARRAY: ==
                    //0 = NAME //1 = DATE
                    //2 = TYPE //3 = FIELD

                    Users  user1     = new Users();
                    string username1 = user.getUsername(senderid);

                    string friendReqBlock = "<div runat='server' style='font-size: 12.5px;' class='py-1 my-1'>Match invite ⚽</div> " +
                                            "<div class='row notif-row my-2'> " +
                                            "<div runat='server'>" + username1 + "#" + senderid + "</div> " +
                                            "<div id='" + matchid + "' class='p-1 m-1'>Match invite</div> " +
                                            "<div id='" + matchid + "#" + code + "@" + type + "' class='btn btn-sm btn-success p-1 m-1' onclick='Goto(this); return true;'>View</div> " +
                                            "</div>";


                    notif.InnerHtml += friendReqBlock;
                }
            }
            if (invited == null && requested == null)
            {
                notif.InnerHtml = "<h6 id='notifEmpty' class='notif-Empty' runat='server'>No notifications. </h6>";
            }
        }