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

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

            return(false);
        }
Beispiel #2
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");
            }
        }
Beispiel #4
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
        }
        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>";
            }
        }