public bool isCodeMatching(string code)
        {
            Matches matchCode = new Matches();
            string  cd        = matchCode.getPvtMatchCode(match_id);

            if (cd == code)
            {
                return(true);
            }

            return(false);
        }
Exemple #2
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 InitiateUpcomingMatches()
        {
            Matches        match       = new Matches();
            List <Matches> matchesList = match.getUpcoming();


            if (matchesList != null)
            {
                for (int i = 0; i < matchesList.Count; i++)
                {
                    createBlockStructure(matchesList[i].id, i);
                }
            }
        }
Exemple #4
0
        public string sendMatchInvite(string receiveid, string senderid, string mid)
        {
            //[invite_id] [invite_resever] [invite_sender] [invite_read] [invite_match]

            Matches match = new Matches();
            string  code  = match.getPvtMatchCode(mid);

            string queryString = "USE ssm_mvc_demo1 INSERT INTO invites (invite_resever, invite_sender, invite_read, invite_match, invite_code)" +
                                 " VALUES (@resever, @sender, @read, @match, @code)";
            string status = "";

            using (SqlConnection connection = new SqlConnection(cs))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                try
                {
                    command.Connection.Open();

                    command.Parameters.AddWithValue("@resever", receiveid);
                    command.Parameters.AddWithValue("@sender", senderid);
                    command.Parameters.AddWithValue("@read", 0);
                    command.Parameters.AddWithValue("@match", mid);
                    command.Parameters.AddWithValue("@code", code);

                    if (command.ExecuteNonQuery() > 0)
                    {
                        status = "good";
                    }
                }
                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");
                    }
                    Console.WriteLine(errorMessages.ToString());
                    status = errorMessages.ToString();
                }
                finally
                {
                    command.Connection.Close();
                }
            }

            return(status);
        }
        protected void GoPrivate_Click(object sender, EventArgs e)
        {
            Matches match = new Matches();
            string  code  = match.getPvtMatchCode(match_id);

            if (match.toggleMatchType(match_id, "Private"))
            {
                Response.Redirect("~/MatchRoom.aspx?match_id=" + match_id + "&type=Private" + "&code=" + code);
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }
Exemple #6
0
        }// AS A CAPTAIN

        public List <Matches> getMyEndedMatches(string uid)
        {
            //USE ssm_mvc_demo1 SELECT match_id, match_name, CONVERT(VARCHAR(10), match_date, 111) AS match_date FROM matches WHERE match_date < GETDATE() AND match_captain='18'

            List <Matches> endedMatches = new List <Matches>();
            //USE ssm_mvc_demo1 SELECT match_id, match_name, CONVERT(VARCHAR(10), match_date, 111) AS match_date FROM matches WHERE match_date > GETDATE() AND match_captain='18'
            string queryString = "USE ssm_mvc_demo1 " +
                                 "SELECT match_id, match_name, CONVERT(VARCHAR(10), match_date, 111) AS match_date " +
                                 "FROM matches " +
                                 "WHERE match_date < GETDATE() AND match_captain=@uid";

            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 = reader[1].ToString();
                        match.date = reader[2].ToString();

                        endedMatches.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());
                }
            }

            return(endedMatches);
        }// AS A CAPTAIN
        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 JoinA_Click(object sender, EventArgs e)
        {
            Matches match = new Matches();

            if (!match.alreadyJoined(user_id, match_id)) // Not joined
            {
                match.joinMatch(user_id, match_id, 1);
            }
            else // Joined already = Leave then => Join
            {
                match.leaveMatch(user_id, match_id);
                match.joinMatch(user_id, match_id, 1);
            }

            Response.Redirect("~/MatchRoom.aspx?match_id=" + match_id);
        }
        protected void invite_Click(object sender, EventArgs e)
        {
            Matches match = new Matches();
            string  st    = match.sendMatchInvite("21", userid, matchid);

            //test.InnerText = match.sendMatchInvite();

            if (st == "good")
            {
                Response.Redirect("/FriendList.aspx?status=3&userid=" + userid + "&matchid=" + matchid + "&invited=yes");
            }
            else
            {
                Response.Redirect("/ErrorPage.aspx");
            }
        }
        public void highlightUsername(int uid)
        {
            Matches match    = new Matches();
            Users   user     = new Users();
            string  username = user.getUsername(uid.ToString());

            currentUser.Value = username;
            if (match.IsTeamFull(match_id, 1))// team A full
            {
                JoinA.Visible = false;
            }
            if (match.IsTeamFull(match_id, 2))// team B full
            {
                JoinB.Visible = false;
            }
        }
Exemple #11
0
        public List <Matches> getUpcoming()
        {
            List <Matches> matchesList = new List <Matches>();

            string queryString = "USE ssm_mvc_demo1 SELECT match_id, match_name, match_date FROM matches WHERE match_date between GETDATE() and GETDATE()+6";

            using (SqlConnection connection = new SqlConnection(cs))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                try
                {
                    command.Connection.Open();

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

                        match.id   = reader[0].ToString();
                        match.name = reader[1].ToString();
                        match.date = reader[2].ToString();


                        matchesList.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();

                    matchesList.Add(error);
                }
            }

            return(matchesList);
        }
        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");
            }
        }
Exemple #13
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);
        }
Exemple #14
0
        public void createMatch_Click(object sender, EventArgs e)
        {
            Matches match     = new Matches();
            bool    isCreated = match.createMatch(matchName.Text, matchType.Text, selectedId.Value, matchDate.Text, matchTime.Text, Session["userid"].ToString());

            if (isCreated)
            {
                if (match.type == "Private")
                {
                    Response.Redirect("~/MatchRoom.aspx?match_id=" + match.id + "&type=" + match.type + "&code=" + match.getPvtMatchCode(match.id));
                }
                if (match.type == "Public")
                {
                    Response.Redirect("~/MatchRoom.aspx?match_id=" + match.id + "&type=" + match.type);
                }

                Response.Redirect("~/MatchRoom.aspx?match_id=" + match.id + "&type=" + "WRONG");
            }

            // should be relocated to my matches page
        }
        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;
                }
            }
        }
Exemple #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] == null || Session["userid"] == null)
            {
                mymatches.InnerHtml = "<h6 id='notifEmpty' class='notif-Empty' runat='server'>Login to see your matches. </h6>";
            }
            else
            {
                userid = Session["userid"].ToString();

                Matches        match               = new Matches();
                List <Matches> openMatches         = match.getMyOpenMatches(userid);       // AS A CAPTAIN
                List <Matches> PlayerJoinedMatches = match.getPlayerJoinedMatches(userid); // AS A PLAYER

                if (openMatches.Count == 0 && PlayerJoinedMatches.Count == 0)              // If there is no matches
                {
                    mymatches.InnerHtml = "<h6 id='notifEmpty' class='notif-Empty' runat='server'>No matches. </h6>";
                }
                else
                {
                    for (int i = 0; i < openMatches.Count(); i++)                           // Loop thru captained matches.
                    {
                        if (openMatches[i].getMatchInfo(openMatches[i].id)[2] == "Private") // Check if match is private.
                        {
                            string code = openMatches[i].getPvtMatchCode(openMatches[i].id);

                            string pvtblock = "<div class='My-matches w-100 p-1 m-2'> " +
                                              "<div class='mym-name'>" + openMatches[i].name + "</div> " +
                                              "<div>" + openMatches[i].date + "</div> " +
                                              "<div id='" + openMatches[i].id + "/" + code + "' class='btn btn-sm btn-dark' onclick='ViewPvtMatch(this);return true;'>View</div> " +
                                              "</div>";



                            mymatches.InnerHtml += pvtblock;
                            mymatches.InnerHtml += "<hr class='my-1 w-75' />";
                        }
                        else
                        {
                            string block = "<div class='My-matches w-100 p-1 m-2'> " +
                                           "<div class='mym-name'>" + openMatches[i].name + "</div> " +
                                           "<div>" + openMatches[i].date + "</div> " +
                                           "<div id='" + openMatches[i].id + "' class='btn btn-sm btn-warning' onclick='ViewMatch(this);return true;'>View</div> " +
                                           "</div>";



                            mymatches.InnerHtml += block;
                            mymatches.InnerHtml += "<hr class='my-1 w-75' />";
                        }
                    }

                    for (int i = 0; i < PlayerJoinedMatches.Count(); i++)
                    {
                        string block = "<div class='My-matches w-100 p-1 m-2'> " +
                                       "<div class='mym-name'>" + PlayerJoinedMatches[i].name + "</div> " +
                                       "<div>" + PlayerJoinedMatches[i].date + "</div> " +
                                       "<div id='" + PlayerJoinedMatches[i].id + "' class='btn btn-sm btn-success' onclick='ViewMatch(this);return true;'>View</div> " +
                                       "</div>";

                        mymatches.InnerHtml += block;
                    }
                }
            }
        }
        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;
        }
        public void fillSlotsTeam2(string mid)
        {
            Matches       match = new Matches();
            List <string> teamA = match.getTeam(mid, 2);

            for (int i = 0; i < teamA.Count(); i++)
            {
                Users  user     = new Users();
                string username = user.getUsername(teamA[i]);

                switch (i)
                {
                case 0:
                    Div11.InnerText           = username;
                    Div11.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 1:
                    Div12.InnerText           = username;
                    Div12.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 2:
                    Div13.InnerText           = username;
                    Div13.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 3:
                    Div14.InnerText           = username;
                    Div14.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 4:
                    Div15.InnerText           = username;
                    Div15.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 5:
                    Div16.InnerText           = username;
                    Div16.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 6:
                    Div17.InnerText           = username;
                    Div17.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 7:
                    Div18.InnerText           = username;
                    Div18.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 8:
                    Div19.InnerText           = username;
                    Div19.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 9:
                    Div20.InnerText           = username;
                    Div20.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;

                case 10:
                    Div21.InnerText           = username;
                    Div21.Attributes["class"] = "row d-flex justify-content-end my-2";
                    break;
                }
            }
        }
        protected void inviteMatch_Click(object sender, EventArgs e)
        {
            Matches match = new Matches();

            Response.Redirect("/FriendList.aspx?status=3&userid=" + user_id + "&matchid=" + match_id);
        }
        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>";
            }
        }
Exemple #21
0
        public List <string[]> getMatchInvites(string uid)
        {
            List <string[]> matchInvites = new List <string[]>();
            Matches         match        = new Matches();
            string          queryString  = "SELECT invite_match, invite_sender FROM invites WHERE invite_resever=@uid";

            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();

                    if (reader.HasRows)
                    {
                        while (reader.Read() && match.checkMatchAvailability(reader.GetValue(0).ToString()))
                        {
                            string[] info = new string[3];

                            //MATCH ID
                            info[0] = reader.GetValue(0).ToString();
                            //SENDER ID
                            info[1] = reader.GetValue(1).ToString();

                            matchInvites.Add(info);
                        }
                    }
                    else
                    {
                        matchInvites = null;
                    }

                    reader.Close();
                }
                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");
                    }
                    Console.WriteLine(errorMessages.ToString());
                    string[] err = new string[1];
                    err[0] = errorMessages.ToString();
                    matchInvites.Add(err);
                }
                finally
                {
                    command.Connection.Close();
                }
            }

            return(matchInvites);
        }