private void BtnRemovePass_Click(object sender, EventArgs e)
        {
            string         rowClicked       = ((Button)sender).ID.Split('_')[1];
            ProfileDisplay profileDisplay   = ((ProfileDisplay)passes.FindControl("pdProfilePass_" + rowClicked));
            string         usernameToRemove = profileDisplay.Username;

            string     url     = "https://localhost:44369/api/DatingService/Profiles/RemoveFromPasses/" + GlobalData.APIKey + "/" + Session["Username"].ToString() + "/" + usernameToRemove;
            WebRequest request = WebRequest.Create(url);

            request.Method        = "DELETE";
            request.ContentLength = 0;

            WebResponse  response      = request.GetResponse();
            Stream       theDataStream = response.GetResponseStream();
            StreamReader reader        = new StreamReader(theDataStream);
            string       data          = reader.ReadToEnd();

            reader.Close();
            response.Close();

            if (data != "true")
            {
                lblErrorMsg.Text   += "*There was an error removing this user from your Passes. <br />";
                lblErrorMsg.Visible = true;
            }
            else
            {
                passes.Controls.RemoveAt(passes.Controls.Count - 1);
                loadPasses();
            }
        }
        private void BtnLikeUser_Click(object sender, EventArgs e)
        {
            string         rowClicked         = ((Button)sender).ID.Split('_')[1];
            ProfileDisplay profileDisplay     = ((ProfileDisplay)passes.FindControl("pdProfilePass_" + rowClicked));
            string         usernameToTransfer = profileDisplay.Username; //get the username of the profile to remove from Passes and add to Likes

            //First remove the profile from Passes List
            string     removeUrl     = "https://localhost:44369/api/DatingService/Profiles/RemoveFromPasses/" + GlobalData.APIKey + "/" + Session["Username"].ToString() + "/" + usernameToTransfer;
            WebRequest removeRequest = WebRequest.Create(removeUrl);

            removeRequest.Method        = "DELETE";
            removeRequest.ContentLength = 0;

            WebResponse  removeResponse   = removeRequest.GetResponse();
            Stream       removeDataStream = removeResponse.GetResponseStream();
            StreamReader removeReader     = new StreamReader(removeDataStream);
            string       removeData       = removeReader.ReadToEnd();

            removeReader.Close();
            removeResponse.Close();

            if (removeData == "true") //if the removal from Passes is successful
            {
                //Now add that profile to Likes List
                string     likeUrl     = "https://localhost:44369/api/DatingService/Profiles/AddLikes/" + GlobalData.APIKey + "/" + Session["Username"].ToString() + "/" + usernameToTransfer;
                WebRequest likeRequest = WebRequest.Create(likeUrl);
                likeRequest.Method        = "PUT";
                likeRequest.ContentLength = 0;

                WebResponse  likeResponse   = likeRequest.GetResponse();
                Stream       likeDataStream = likeResponse.GetResponseStream();
                StreamReader likeReader     = new StreamReader(likeDataStream);
                string       likeData       = likeReader.ReadToEnd();
                likeReader.Close();
                likeResponse.Close();

                if (likeData == "1") //if the transfer works, then reload Likes and Passes Lists
                {
                    likes.Controls.RemoveAt(likes.Controls.Count - 1);
                    loadLikes();

                    passes.Controls.RemoveAt(passes.Controls.Count - 1);
                    loadPasses();
                }
                else
                {
                    lblErrorMsg.Text   += "*There was an error moving this user to your Likes. <br />";
                    lblErrorMsg.Visible = true;
                }
            }
            else
            {
                lblErrorMsg.Text   += "*There was an error removing this user from your Passes. <br />";
                lblErrorMsg.Visible = true;
            }
        }
Exemplo n.º 3
0
        private void BtnMessage_Click(object sender, EventArgs e)
        {
            Button         btnMessage     = (Button)sender;
            int            rowNum         = int.Parse(btnMessage.ID.Split('_')[1]);
            ProfileDisplay profileDisplay = ((ProfileDisplay)conversationsDiv.FindControl("pdProfile_" + rowNum));

            Session.Add("MessageToUsername", profileDisplay.Username);

            MessagingDisplay1.To = profileDisplay.Username;
            MessagingDisplay1.DataBind();

            sendMsgDiv.Visible = true;
        }
Exemplo n.º 4
0
        private Table generateConversationsTable(List <ProfileDisplayClass> userProfiles)
        {
            Table tblProfileList = new Table();

            tblProfileList.HorizontalAlign = HorizontalAlign.Center;
            tblProfileList.GridLines       = GridLines.Horizontal;
            tblProfileList.BorderStyle     = BorderStyle.None;
            tblProfileList.CellPadding     = 5;
            tblProfileList.Style.Add("width", "70%");

            TableRow       row            = null;
            TableCell      cell           = null;
            ProfileDisplay profileDisplay = null;

            for (int i = 0; i < userProfiles.Count; i++)
            {
                row                      = new TableRow();
                cell                     = new TableCell();
                profileDisplay           = (ProfileDisplay)LoadControl("ProfileDisplay.ascx");
                profileDisplay.ID        = "pdProfile_" + i;
                profileDisplay.Username  = userProfiles[i].Username;
                profileDisplay.FirstName = userProfiles[i].FirstName;
                profileDisplay.LastName  = userProfiles[i].LastName;
                profileDisplay.Title     = userProfiles[i].Title;
                profileDisplay.Age       = userProfiles[i].Age;
                profileDisplay.ImageUrl  = convertByteArrayToImage(userProfiles[i].Username);
                cell.Controls.Add(profileDisplay);

                TableCell messageCell = new TableCell();
                Button    btnMessage  = new Button();
                btnMessage.ID       = "btnMessage_" + i;
                btnMessage.Click   += BtnMessage_Click;
                btnMessage.Text     = "Message";
                btnMessage.CssClass = "btn btn-outline-success";
                messageCell.Controls.Add(btnMessage);

                TableCell deleteCell = new TableCell();
                Button    btnDelete  = new Button();
                btnDelete.ID       = "btnDelete_" + i;
                btnDelete.Click   += BtnDelete_Click;
                btnDelete.Text     = "Delete Conversation";
                btnDelete.CssClass = "btn btn-outline-danger";
                deleteCell.Controls.Add(btnDelete);

                row.Cells.Add(cell);
                row.Cells.Add(messageCell);
                row.Cells.Add(deleteCell);
                tblProfileList.Rows.Add(row);
            }
            return(tblProfileList);
        }
        private Table generatePassesListTable(List <ProfileDisplayClass> userProfiles)
        {
            Table tblProfileList = new Table();

            tblProfileList.HorizontalAlign = HorizontalAlign.Center;
            tblProfileList.GridLines       = GridLines.Horizontal;
            tblProfileList.BorderStyle     = BorderStyle.None;
            tblProfileList.CellPadding     = 5;
            tblProfileList.Style.Add("width", "95%");
            TableRow       row            = null;
            TableCell      cell           = null;
            ProfileDisplay profileDisplay = null;

            for (int i = 0; i < userProfiles.Count; i++)
            {
                row                      = new TableRow();
                cell                     = new TableCell();
                profileDisplay           = (ProfileDisplay)LoadControl("ProfileDisplay.ascx");
                profileDisplay.ID        = "pdProfilePass_" + i;
                profileDisplay.Username  = userProfiles[i].Username;
                profileDisplay.FirstName = userProfiles[i].FirstName;
                profileDisplay.LastName  = userProfiles[i].LastName;
                profileDisplay.Title     = userProfiles[i].Title;
                profileDisplay.Age       = userProfiles[i].Age;
                profileDisplay.ImageUrl  = convertByteArrayToImage(userProfiles[i].Username);
                cell.Controls.Add(profileDisplay);

                TableCell likeUserCell = new TableCell();
                Button    btnLikeUser  = new Button();
                btnLikeUser.ID       = "btnLikeUser_" + i;
                btnLikeUser.Text     = "Like";
                btnLikeUser.CssClass = "btn btn-outline-success";
                btnLikeUser.Click   += BtnLikeUser_Click;
                likeUserCell.Controls.Add(btnLikeUser);

                TableCell removePassCell = new TableCell();
                Button    btnRemovePass  = new Button();
                btnRemovePass.ID       = "btnRemovePass_" + i;
                btnRemovePass.Text     = "Remove from Passes";
                btnRemovePass.CssClass = "btn btn-outline-danger";
                btnRemovePass.Click   += BtnRemovePass_Click;
                removePassCell.Controls.Add(btnRemovePass);

                row.Cells.Add(cell);
                row.Cells.Add(likeUserCell);
                row.Cells.Add(removePassCell);
                tblProfileList.Rows.Add(row);
            }
            return(tblProfileList);
        }
Exemplo n.º 6
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            Button         btnDelete      = (Button)sender;
            int            rowNum         = int.Parse(btnDelete.ID.Split('_')[1]);
            ProfileDisplay profileDisplay = ((ProfileDisplay)conversationsDiv.FindControl("pdProfile_" + rowNum));

            DBConnect  objDB  = new DBConnect();
            SqlCommand objCmd = new SqlCommand();

            objCmd.CommandType = CommandType.StoredProcedure;
            objCmd.CommandText = "TP_DeleteConversation";
            objCmd.Parameters.AddWithValue("@usernameOne", Session["Username"].ToString());
            objCmd.Parameters.AddWithValue("@usernameTwo", profileDisplay.Username);

            int result = objDB.DoUpdateUsingCmdObj(objCmd);

            if (result == 1)
            {
                conversationsDiv.Controls.RemoveAt(conversationsDiv.Controls.Count - 1);
                loadConversations();
            }
        }
        private Table generateResultsTable(List <ProfileDisplayClass> userProfiles)
        {
            Table tblProfileList = new Table();

            tblProfileList.HorizontalAlign = HorizontalAlign.Center;
            tblProfileList.GridLines       = GridLines.Horizontal;
            tblProfileList.BorderStyle     = BorderStyle.None;
            tblProfileList.CellPadding     = 5;
            tblProfileList.Style.Add("width", "70%");


            TableRow       row            = null;
            TableCell      cell           = null;
            ProfileDisplay profileDisplay = null;

            for (int i = 0; i < userProfiles.Count; i++)
            {
                row                      = new TableRow();
                row.CssClass             = "text-center";
                cell                     = new TableCell();
                cell.CssClass            = "text-center";
                profileDisplay           = (ProfileDisplay)LoadControl("ProfileDisplay.ascx");
                profileDisplay.ID        = "pdProfile_" + i;
                profileDisplay.Username  = userProfiles[i].Username;
                profileDisplay.FirstName = userProfiles[i].FirstName;
                profileDisplay.LastName  = userProfiles[i].LastName;
                profileDisplay.Title     = userProfiles[i].Title;
                profileDisplay.Age       = userProfiles[i].Age;
                profileDisplay.ImageUrl  = convertByteArrayToImage(userProfiles[i].Username);
                cell.Controls.Add(profileDisplay);

                row.Cells.Add(cell);
                tblProfileList.Rows.Add(row);
            }
            return(tblProfileList);
        }
Exemplo n.º 8
0
        private void DdChooseAction_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddChooseAction = (DropDownList)sender;

            if (ddChooseAction.SelectedIndex == 0)
            {
                lblErrorMsg.Text   += "*Please select a valid response to the date request. <br />";
                lblErrorMsg.Visible = true;
            }
            else
            {
                int            rowNum         = int.Parse(ddChooseAction.ID.Split('_')[1]);
                ProfileDisplay profileDisplay = ((ProfileDisplay)received.FindControl("pdProfileReceived_" + rowNum));

                User tempUser   = new User();
                int  userIDFrom = tempUser.getUserID(profileDisplay.Username);
                int  userIDTo   = tempUser.getUserID(Session["Username"].ToString());

                DateRequest dateRequest = new DateRequest();
                dateRequest.UserIDFrom = userIDFrom;
                dateRequest.UserIDTo   = userIDTo;
                dateRequest.Status     = ddChooseAction.SelectedValue;

                JavaScriptSerializer js   = new JavaScriptSerializer();
                string jsonDateRequestObj = js.Serialize(dateRequest);

                try
                {
                    string     url     = "https://localhost:44369/api/DatingService/Profiles/UpdateDateRequestStatus/" + GlobalData.APIKey;
                    WebRequest request = WebRequest.Create(url);
                    request.Method        = "PUT";
                    request.ContentLength = jsonDateRequestObj.Length;
                    request.ContentType   = "application/json";

                    //Write the JSON data to the Web Request
                    StreamWriter writer = new StreamWriter(request.GetRequestStream());
                    writer.Write(jsonDateRequestObj);
                    writer.Flush();
                    writer.Close();

                    //Read the data from the Web Response
                    WebResponse  response      = request.GetResponse();
                    Stream       theDataStream = response.GetResponseStream();
                    StreamReader reader        = new StreamReader(theDataStream);
                    string       data          = reader.ReadToEnd();
                    reader.Close();
                    response.Close();

                    if (data == "true")
                    {
                        received.Controls.RemoveAt(received.Controls.Count - 1);
                        loadReceivedRequests();
                    }
                    else
                    {
                        lblErrorMsg.Text   += "*A problem occured while updating the status of the date request. <br />";
                        lblErrorMsg.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    lblErrorMsg.Text   += "*Error: " + ex.Message + "<br />";
                    lblErrorMsg.Visible = true;
                }
            }
        }
Exemplo n.º 9
0
        private Table generateReceivedRequestsTable(List <DateRequest> receivedDateRequests, List <ProfileDisplayClass> userProfiles)
        {
            Table tblProfileList = new Table();

            tblProfileList.HorizontalAlign = HorizontalAlign.Center;
            tblProfileList.GridLines       = GridLines.Horizontal;
            tblProfileList.BorderStyle     = BorderStyle.None;
            tblProfileList.CellPadding     = 5;
            tblProfileList.Style.Add("width", "95%");

            TableHeaderRow  headerRow = new TableHeaderRow();
            TableHeaderCell headerCellReceivedFrom = new TableHeaderCell();

            headerCellReceivedFrom.ID   = "headerCellReceivedFrom";
            headerCellReceivedFrom.Text = "Received From";
            headerRow.Cells.Add(headerCellReceivedFrom);

            TableHeaderCell headerCellStatus = new TableHeaderCell();

            headerCellStatus.ID   = "headerCellStatusReceived";
            headerCellStatus.Text = "Status";
            headerRow.Cells.Add(headerCellStatus);

            TableHeaderCell headerCellChoose = new TableHeaderCell();

            headerCellChoose.ID   = "headerCellChoose";
            headerCellChoose.Text = "Choose";
            headerRow.Cells.Add(headerCellChoose);

            TableHeaderCell headerCellPlanDate = new TableHeaderCell();

            headerCellPlanDate.ID   = "headerCellPlanDateReceived";
            headerCellPlanDate.Text = "Plan Date";
            headerRow.Cells.Add(headerCellPlanDate);

            tblProfileList.Rows.Add(headerRow);

            TableRow       row            = null;
            TableCell      cell           = null;
            ProfileDisplay profileDisplay = null;

            for (int i = 0; i < userProfiles.Count; i++)
            {
                row                      = new TableRow();
                cell                     = new TableCell();
                profileDisplay           = (ProfileDisplay)LoadControl("ProfileDisplay.ascx");
                profileDisplay.ID        = "pdProfileReceived_" + i;
                profileDisplay.Username  = userProfiles[i].Username;
                profileDisplay.FirstName = userProfiles[i].FirstName;
                profileDisplay.LastName  = userProfiles[i].LastName;
                profileDisplay.Title     = userProfiles[i].Title;
                profileDisplay.Age       = userProfiles[i].Age;
                profileDisplay.ImageUrl  = convertByteArrayToImage(userProfiles[i].Username);
                cell.Controls.Add(profileDisplay);

                TableCell statusCell = new TableCell();
                Label     lblStatus  = new Label();
                lblStatus.ID   = "lblStatusReceived_" + i;
                lblStatus.Text = receivedDateRequests[i].Status;
                statusCell.Controls.Add(lblStatus);

                TableCell    chooseActionCell = new TableCell();
                DropDownList ddChooseAction   = new DropDownList();
                ddChooseAction.AutoPostBack          = true;
                ddChooseAction.ID                    = "ddChooseAction_" + i;
                ddChooseAction.CssClass              = "form-control";
                ddChooseAction.SelectedIndexChanged += DdChooseAction_SelectedIndexChanged;
                ddChooseAction.Items.Add(new ListItem("", "Select"));
                ddChooseAction.Items.Add(new ListItem("Accept", "Accepted"));
                ddChooseAction.Items.Add(new ListItem("Decline", "Declined"));
                ddChooseAction.Items.Add(new ListItem("Ignore", "Ignored"));
                ddChooseAction.SelectedIndex = 0;
                if (receivedDateRequests[i].Status.Equals("Accepted"))
                {
                    ddChooseAction.Enabled = false;
                }
                else
                {
                    ddChooseAction.Enabled = true;
                }
                chooseActionCell.Controls.Add(ddChooseAction);

                TableCell planDateCell = new TableCell();
                Button    btnPlanDate  = new Button();
                btnPlanDate.ID       = "btnPlanDateReceived_" + i;
                btnPlanDate.Click   += BtnPlanDate_Click;
                btnPlanDate.Text     = "Plan Date";
                btnPlanDate.CssClass = "btn btn-outline-success";
                if (receivedDateRequests[i].Status.Equals("Accepted"))
                {
                    btnPlanDate.Enabled = true;
                }
                else
                {
                    btnPlanDate.Enabled = false;
                }
                planDateCell.Controls.Add(btnPlanDate);

                row.Cells.Add(cell);
                row.Cells.Add(statusCell);
                row.Cells.Add(chooseActionCell);
                row.Cells.Add(planDateCell);

                tblProfileList.Rows.Add(row);
            }
            return(tblProfileList);
        }
Exemplo n.º 10
0
        private Table generateSentRequestsTable(List <DateRequest> sentDateRequests, List <ProfileDisplayClass> userProfiles)
        {
            Table tblProfileList = new Table();

            tblProfileList.HorizontalAlign = HorizontalAlign.Center;
            tblProfileList.GridLines       = GridLines.Horizontal;
            tblProfileList.BorderStyle     = BorderStyle.None;
            tblProfileList.CellPadding     = 5;
            tblProfileList.Style.Add("width", "95%");

            TableHeaderRow  headerRow        = new TableHeaderRow();
            TableHeaderCell headerCellSentTo = new TableHeaderCell();

            headerCellSentTo.ID   = "headerCellSentTo";
            headerCellSentTo.Text = "Sent To";
            headerRow.Cells.Add(headerCellSentTo);

            TableHeaderCell headerCellStatus = new TableHeaderCell();

            headerCellStatus.ID   = "headerCellStatusSent";
            headerCellStatus.Text = "Status";
            headerRow.Cells.Add(headerCellStatus);

            TableHeaderCell headerCellPlanDate = new TableHeaderCell();

            headerCellPlanDate.ID   = "headerCellPlanDateSent";
            headerCellPlanDate.Text = "Plan Date";
            headerRow.Cells.Add(headerCellPlanDate);

            tblProfileList.Rows.Add(headerRow);

            TableRow       row            = null;
            TableCell      cell           = null;
            ProfileDisplay profileDisplay = null;

            for (int i = 0; i < userProfiles.Count; i++)
            {
                row                      = new TableRow();
                cell                     = new TableCell();
                profileDisplay           = (ProfileDisplay)LoadControl("ProfileDisplay.ascx");
                profileDisplay.ID        = "pdProfileSent_" + i;
                profileDisplay.Username  = userProfiles[i].Username;
                profileDisplay.FirstName = userProfiles[i].FirstName;
                profileDisplay.LastName  = userProfiles[i].LastName;
                profileDisplay.Title     = userProfiles[i].Title;
                profileDisplay.Age       = userProfiles[i].Age;
                profileDisplay.ImageUrl  = convertByteArrayToImage(userProfiles[i].Username);
                cell.Controls.Add(profileDisplay);

                TableCell statusCell = new TableCell();
                Label     lblStatus  = new Label();
                lblStatus.ID   = "lblStatusSent_" + i;
                lblStatus.Text = sentDateRequests[i].Status;
                statusCell.Controls.Add(lblStatus);

                TableCell planDateCell = new TableCell();
                Button    btnPlanDate  = new Button();
                btnPlanDate.ID       = "btnPlanDateSent_" + i;
                btnPlanDate.Click   += BtnPlanDate_Click;
                btnPlanDate.Text     = "Plan Date";
                btnPlanDate.CssClass = "btn btn-outline-success";
                if (sentDateRequests[i].Status.Equals("Accepted"))
                {
                    btnPlanDate.Enabled = true;
                }
                else
                {
                    btnPlanDate.Enabled = false;
                }
                planDateCell.Controls.Add(btnPlanDate);

                row.Cells.Add(cell);
                row.Cells.Add(statusCell);
                row.Cells.Add(planDateCell);
                tblProfileList.Rows.Add(row);
            }
            return(tblProfileList);
        }