public string FindFriendsurname(object ID) { string name = ""; int personId = -5; string adm = Session["personId"].ToString(); int adminId = Convert.ToInt32(adm); // string newTeam = ""; int friendId = Convert.ToInt32(ID); using (BOOKGRAMEntities db = new BOOKGRAMEntities()) { Friend te = (from x in db.Friend where x.FriendId == friendId select x).SingleOrDefault(); if (te != null) { if (te.Friend1Id == adminId) { personId = te.Friend2Id.Value; } else { personId = te.Friend1Id.Value; } } } BOOKGRAMEntities db2 = new BOOKGRAMEntities(); Person pe = (from x in db2.Person where x.PersonId == personId select x).SingleOrDefault(); name = pe.LastName; return(name); }
protected void btnSend_Click(object sender, EventArgs e) { String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); string nameSurname; string[] values; string name; string surname; BOOKGRAMEntities db = new BOOKGRAMEntities(); MessageList sendMesseage = new MessageList(); sendMesseage.IsActive = true; sendMesseage.IsRead = false; sendMesseage.MessageText = txtMesseage.Text; sendMesseage.senderUserId = supid; nameSurname = ddlReceiver.Text; values = nameSurname.Split(' '); name = values[0]; surname = values[1]; Person t = (from x in db.Person where x.FirstName == name && x.LastName == surname select x).SingleOrDefault(); sendMesseage.receiverUserId = t.PersonId; db.MessageList.Add(sendMesseage); db.SaveChanges(); Response.Redirect("Messeage.aspx"); }
public List <Post> CategoryBnd() { int cnt = 0; BOOKGRAMEntities db = new BOOKGRAMEntities(); String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); Post[] postList = (from x in db.Post where x.IsActive == true && x.PersonId == supid select x).ToArray(); List <Post> post = new List <Post>(); Post p = new Post(); while (cnt < postList.Length) { post.Add(new Post() { PostId = postList[cnt].PostId, PostText = postList[cnt].PostText, ImagePath = postList[cnt].ImagePath, Dislike_num = postList[cnt].Dislike_num, Like_num = postList[cnt].Like_num, }); cnt++; } return(post); }
protected void btnLogin_Click(object sender, EventArgs e) { LoginService ls = new LoginService(); Hashing h = new Hashing(); // h.HashPassword string username = txtEmail.Text; string password = txtPassword.Text; BOOKGRAMEntities db = new BOOKGRAMEntities(); Person[] personList = (from x in db.Person select x).ToArray(); Person a = ls.isValidPerson(username, password); if (a != null) { for (int i = 0; i < personList.Length; i++) { //if (personList[i].Username == username && personList[i].Password == password && personList[i].isActive == true) //{ Session["personInfo"] = a.FirstName; Session["personSurname"] = a.LastName; Session["personId"] = a.PersonId; Response.Redirect("Default.aspx"); //} } } else { lblMesseage.Visible = true; lblMesseage.Text = "Please check your information"; } }
public List <Comment> CategoryBnd() { String spt = Session["postId"].ToString(); int supid = Convert.ToInt32(spt); int cnt = 0; BOOKGRAMEntities db = new BOOKGRAMEntities(); Comment[] commentList = (from x in db.Comment where x.IsActive == true && x.PostId == supid select x).ToArray(); List <Comment> comment = new List <Comment>(); Comment p = new Comment(); while (cnt < commentList.Length) { comment.Add(new Comment() { PostId = commentList[cnt].PostId, CommentText = commentList[cnt].CommentText, PersonId = commentList[cnt].PersonId, IsActive = commentList[cnt].IsActive, CommentId = commentList[cnt].CommentId, }); cnt++; } return(comment); }
public List <Post> CategoryBnd() { int cnt = 0; string[] values; int id; string name, surname, NameSurname; BOOKGRAMEntities db = new BOOKGRAMEntities(); NameSurname = ddlName.SelectedValue.ToString(); values = NameSurname.Split(' '); name = values[0]; surname = values[1]; Person te = (from x in db.Person where x.FirstName == name && x.LastName == surname select x).SingleOrDefault(); id = te.PersonId; Post[] postList = (from x in db.Post where x.IsActive == true && x.PersonId == id select x).ToArray(); List <Post> post = new List <Post>(); Post p = new Post(); while (cnt < postList.Length) { post.Add(new Post() { PostId = postList[cnt].PostId, PostText = postList[cnt].PostText, ImagePath = postList[cnt].ImagePath, Dislike_num = postList[cnt].Dislike_num, Like_num = postList[cnt].Like_num, }); cnt++; } return(post); }
protected void grdSupUpdate_UpdatingRows(object sender, GridViewUpdateEventArgs e) { String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); GridViewRow row = (GridViewRow)grdSupUpdate.Rows[e.RowIndex]; Label lbldeleteid = (Label)row.FindControl("lblId"); TextBox txtNewName = (TextBox)row.FindControl("txtNumber"); TextBox txtCity = (TextBox)row.FindControl("txtCity"); BOOKGRAMEntities db = new BOOKGRAMEntities(); int id = Convert.ToInt32(lbldeleteid.Text); Person c = (from x in db.Person where x.PersonId == id && x.IsActive == true && x.PersonId == supid select x).SingleOrDefault(); c.Email = txtNewName.Text; c.City = txtCity.Text; db.SaveChanges(); grdSupUpdate.EditIndex = -1; Person[] teamList = (from x in db.Person where x.IsActive == true && x.PersonId == supid select x).ToArray(); grdSupUpdate.DataSource = teamList; grdSupUpdate.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { string message = "Successfully friendship!!"; string adm = Session["personId"].ToString(); int adminId = Convert.ToInt32(adm); BOOKGRAMEntities db = new BOOKGRAMEntities(); for (int i = 0; i < grdConfirmSupported.Rows.Count; i++) { GridViewRow row = (GridViewRow)grdConfirmSupported.Rows[i]; CheckBox chkNew = (CheckBox)row.FindControl("chkConfirm"); Label lblName = (Label)row.FindControl("lblFirstName"); Label lblSurname = (Label)row.FindControl("lblLastname"); Person c = (from x in db.Person where x.FirstName == lblName.Text && x.IsActive == true select x).SingleOrDefault(); int id = c.PersonId; if (chkNew.Checked) { // message += lblName.Text; Friend p = (from x in db.Friend where x.isActive == false && ((x.Friend1Id == id && x.Friend2Id == adminId) || (x.Friend2Id == id && x.Friend1Id == adminId)) select x).SingleOrDefault(); p.isActive = true; db.SaveChanges(); } } lblMessage.Text = message; grdConfirmSupported.Visible = false; Button1.Visible = false; }
protected void grdSupUpdate_cancelingRows(object sender, GridViewCancelEditEventArgs e) { grdSupUpdate.EditIndex = -1; String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); BOOKGRAMEntities db = new BOOKGRAMEntities(); Person[] teamList = (from x in db.Person where x.IsActive == true && x.PersonId == supid select x).ToArray(); grdSupUpdate.DataSource = teamList; grdSupUpdate.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BOOKGRAMEntities db = new BOOKGRAMEntities(); string adm = Session["personId"].ToString(); int adminId = Convert.ToInt32(adm); Friend[] friendList = (from x in db.Friend where x.isActive == false && (x.Friend1Id == adminId || x.Friend2Id == adminId) select x).ToArray(); grdConfirmSupported.DataSource = friendList; grdConfirmSupported.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BOOKGRAMEntities db = new BOOKGRAMEntities(); String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); Person[] teamList = (from x in db.Person where x.IsActive == true && x.PersonId == supid select x).ToArray(); grdSupUpdate.DataSource = teamList; grdSupUpdate.DataBind(); } }
protected void grdTeamOp_RowsCanceling(object sender, GridViewCancelEditEventArgs e) { grdTeamOp.EditIndex = -1; BOOKGRAMEntities db = new BOOKGRAMEntities(); String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); Friend[] friendList = (from x in db.Friend where x.isActive == true && (x.Friend1Id == supid || x.Friend2Id == supid) select x).ToArray(); db.SaveChanges(); grdTeamOp.DataSource = friendList; grdTeamOp.DataBind(); }
public Person isValidPerson(string username, string password) { BOOKGRAMEntities db = new BOOKGRAMEntities(); Hashing h = new Hashing(); Person s = (from x in db.Person where x.Username == username && x.IsActive == true select x).SingleOrDefault(); if (h.VerifyPassword(password, s.Password.ToString())) { return(s); } else { return(null); } }
protected void grdTeamOp_RowsCanceling(object sender, GridViewCancelEditEventArgs e) { int frid; grdTeamOp.EditIndex = -1; BOOKGRAMEntities db = new BOOKGRAMEntities(); string adm = Session["personId"].ToString(); int adminId = Convert.ToInt32(adm); Person pe = (from x in db.Person where x.PersonId == adminId select x).SingleOrDefault(); frid = pe.PersonId; Friend[] friendList = (from x in db.Friend where x.isActive == true && (x.Friend1Id == frid || x.Friend2Id == frid) select x).ToArray(); grdTeamOp.DataSource = friendList; grdTeamOp.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int flg = 0; BOOKGRAMEntities db = new BOOKGRAMEntities(); String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); Friend[] friendList = (from x in db.Friend where x.isActive == true && (x.Friend1Id == supid || x.Friend2Id == supid) select x).ToArray(); grdTeamOp.DataSource = friendList; grdTeamOp.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int frid; string adm = Session["personId"].ToString(); int adminId = Convert.ToInt32(adm); BOOKGRAMEntities db = new BOOKGRAMEntities(); Person pe = (from x in db.Person where x.PersonId == adminId select x).SingleOrDefault(); frid = pe.PersonId; Friend[] friendList = (from x in db.Friend where x.isActive == true && (x.Friend1Id == frid || x.Friend2Id == frid) select x).ToArray(); grdTeamOp.DataSource = friendList; grdTeamOp.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); BOOKGRAMEntities db = new BOOKGRAMEntities(); int value; MessageList[] messeageList = (from x in db.MessageList where x.IsActive == true && x.receiverUserId == supid select x).ToArray(); List <int> idList = new List <int>(); string nameSurname; List <string> nameList = new List <string>(); //firstly take receiver personId for (int i = 0; i < messeageList.Length; i++) { value = messeageList[i].senderUserId.Value; idList.Add(value); } for (int i = 0; i < idList.Count; i++) { for (int j = i + 1; j < idList.Count; j++) { if (idList[i] == idList[j]) { idList.RemoveAt(i); } } } //secondly take name+surname for (int i = 0; i < idList.Count; i++) { value = idList[i]; Person te = (from x in db.Person where x.PersonId == value select x).SingleOrDefault(); nameSurname = te.FirstName + " " + te.LastName; nameList.Add(nameSurname); } //write to ddl for (int i = 0; i < idList.Count; i++) { ddlReceiver.Items.Add(nameList[i]); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); String nameSurname; BOOKGRAMEntities db = new BOOKGRAMEntities(); Person[] personList = (from x in db.Person where x.IsActive == true && x.PersonId != supid select x).ToArray(); for (int i = 0; i < personList.Length; i++) { nameSurname = personList[i].FirstName + " " + personList[i].LastName; ddlName.Items.Add(nameSurname); } } }
protected void grdTeamOp_RowsDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = (GridViewRow)grdTeamOp.Rows[e.RowIndex]; Label lbldeleteid = (Label)row.FindControl("lblId"); BOOKGRAMEntities db = new BOOKGRAMEntities(); int id = Convert.ToInt32(lbldeleteid.Text); Friend c = (from x in db.Friend where x.FriendId == id && x.isActive == true select x).SingleOrDefault(); if (c != null) { c.isActive = false; } db.SaveChanges(); grdTeamOp.DataBind(); }
protected void btnSend_Click(object sender, EventArgs e) { String spt = Session["postId"].ToString(); int supid = Convert.ToInt32(spt); String sspt = Session["personId"].ToString(); int perid = Convert.ToInt32(sspt); //lblPostId.Text = spt; BOOKGRAMEntities db = new BOOKGRAMEntities(); Comment newComment = new Comment(); newComment.CommentText = txtPost.Text; newComment.IsActive = true; newComment.PostId = supid; newComment.PersonId = perid; db.Comment.Add(newComment); db.SaveChanges(); Response.Redirect("CommentPage.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); BOOKGRAMEntities db = new BOOKGRAMEntities(); int value; Friend[] friendList = (from x in db.Friend where x.isActive == true && (x.Friend1Id == supid || x.Friend2Id == supid) select x).ToArray(); List <Person> personList = new List <Person>(); List <int> idList = new List <int>(); string nameSurname; List <string> nameList = new List <string>(); int id; Person p = new Person(); //firstly take receiver personId for (int i = 0; i < friendList.Length; i++) { if (friendList[i].Friend1Id == supid) { id = friendList[i].Friend2Id.Value; } else { id = friendList[i].Friend1Id.Value; } idList.Add(id); } //secondly take name+surname for (int i = 0; i < idList.Count; i++) { value = idList[i]; Person te = (from x in db.Person where x.PersonId == value select x).SingleOrDefault(); nameSurname = te.FirstName + " " + te.LastName; nameList.Add(nameSurname); } //write to ddl for (int i = 0; i < idList.Count; i++) { ddlReceiver.Items.Add(nameList[i]); } } }
protected void btnSave_Click(object sender, EventArgs e) { RegService rg = new RegService(); BOOKGRAMEntities db = new BOOKGRAMEntities(); Person newSupporter = new Person(); newSupporter.FirstName = txtboxName.Text; newSupporter.LastName = txtboxSurname.Text; newSupporter.Email = txtboxEmail.Text; newSupporter.BirthDate = Convert.ToDateTime(txtboxDate.Text); newSupporter.City = txtboxAddress.Text; newSupporter.Friend_num = 0; //HIDEYI SOR newSupporter.IsActive = true; newSupporter.Post_num = 0; newSupporter.Message_num = 0; newSupporter.Username = txtboxUsername.Text; newSupporter.Friend_num = 0; newSupporter.Password = rg.makePersonPassword(txtboxPass.Text); if (fuLogoUp.HasFile) { fuLogoUp.SaveAs(Server.MapPath("~/Logos/" + fuLogoUp.FileName)); } newSupporter.Imagepath = "~/Logos/" + fuLogoUp.FileName; if (chcBox.Checked == true) { newSupporter.Hide = true; } else { newSupporter.Hide = false; } db.Person.Add(newSupporter); db.SaveChanges(); Response.Redirect("Register.aspx"); }
public string FindImage(object ID) { string ImagePathh = ""; int postID = Convert.ToInt32(ID); using (BOOKGRAMEntities db = new BOOKGRAMEntities()) { Post te = (from x in db.Post where x.PostId == postID select x).SingleOrDefault(); if (te != null) { if (te.PostTypeId == 2) { ImagePathh = te.ImagePath.ToString(); } } } return(ImagePathh); }
protected void ddlEnter_SelectedIndexChanged(object sender, EventArgs e) { string[] values; int id; string name, surname, NameSurname; BOOKGRAMEntities db = new BOOKGRAMEntities(); NameSurname = ddlName.SelectedValue.ToString(); values = NameSurname.Split(' '); name = values[0]; surname = values[1]; Person te = (from x in db.Person where x.FirstName == name && x.LastName == surname select x).SingleOrDefault(); id = te.PersonId; String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); Friend f = (from x in db.Friend where x.isActive == true && ((x.Friend1Id == supid && x.Friend2Id == id) || x.Friend2Id == supid && x.Friend1Id == id) select x).SingleOrDefault(); if (f == null) { if (te.Hide == false) { //can see rptCategories.DataSource = CategoryBnd(); rptCategories.DataBind(); } else { //not see lblUyari.Visible = true; } } else { //can see rptCategories.DataSource = CategoryBnd(); rptCategories.DataBind(); } }
public string FindAvatar(object ID) { string AvatarPath = ""; // string newTeam = ""; int postID = Convert.ToInt32(ID); int personID; using (BOOKGRAMEntities db = new BOOKGRAMEntities()) { Post pt = (from x in db.Post where x.PostId == postID select x).SingleOrDefault(); personID = pt.PersonId.Value; Person te = (from x in db.Person where x.PersonId == personID select x).SingleOrDefault(); if (te != null) { AvatarPath = te.Imagepath.ToString(); } } return(AvatarPath); }
public string FindSenderSurName(object ID) { string name = ""; int personID; // string newTeam = ""; int messeageId = Convert.ToInt32(ID); using (BOOKGRAMEntities db = new BOOKGRAMEntities()) { MessageList pt = (from x in db.MessageList where x.MessageId == messeageId select x).SingleOrDefault(); personID = pt.senderUserId.Value; Person te = (from x in db.Person where x.PersonId == personID select x).SingleOrDefault(); if (te != null) { name = te.LastName; } } return(name); }
public string FindSenderName(object ID) { string name = ""; int personID; // string newTeam = ""; int postID = Convert.ToInt32(ID); using (BOOKGRAMEntities db = new BOOKGRAMEntities()) { Post pt = (from x in db.Post where x.PostId == postID select x).SingleOrDefault(); personID = pt.PersonId.Value; Person te = (from x in db.Person where x.PersonId == personID select x).SingleOrDefault(); if (te != null) { name = te.FirstName; } } return(name); }
public List <MessageList> CategoryBnd() { int cnt = 0; string NameSurname; string[] values; string name; string surname; int id; NameSurname = ddlReceiver.SelectedValue.ToString(); values = NameSurname.Split(' '); name = values[0]; surname = values[1]; BOOKGRAMEntities db = new BOOKGRAMEntities(); Person te = (from x in db.Person where x.FirstName == name && x.LastName == surname select x).SingleOrDefault(); id = te.PersonId; String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); MessageList[] messeageList = (from x in db.MessageList where x.IsActive == true && x.receiverUserId == supid && x.senderUserId == id select x).ToArray(); List <MessageList> post = new List <MessageList>(); MessageList mList = new MessageList(); while (cnt < messeageList.Length) { post.Add(new MessageList() { MessageId = messeageList[cnt].MessageId, MessageText = messeageList[cnt].MessageText, senderUserId = messeageList[cnt].senderUserId, receiverUserId = messeageList[cnt].receiverUserId, IsActive = messeageList[cnt].IsActive, }); cnt++; } return(post); }
protected void grdTeamOp_RowsDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = (GridViewRow)grdTeamOp.Rows[e.RowIndex]; Label lbldeleteid = (Label)row.FindControl("lblId"); BOOKGRAMEntities db = new BOOKGRAMEntities(); int id = Convert.ToInt32(lbldeleteid.Text); String spt = Session["personId"].ToString(); int supid = Convert.ToInt32(spt); Friend newFriend = new Friend(); newFriend.Friend1Id = supid; newFriend.Friend2Id = id; newFriend.isActive = false; db.Friend.Add(newFriend); db.SaveChanges(); grdTeamOp.DataBind(); Response.Redirect("FriendList.aspx"); }
protected void rptCategories_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.ToString() == "like") { BOOKGRAMEntities db = new BOOKGRAMEntities(); int postId; String id; id = e.CommandArgument.ToString(); postId = Convert.ToInt32(id); Post te = (from x in db.Post where x.PostId == postId select x).SingleOrDefault(); te.Like_num++; db.SaveChanges(); Response.Redirect("Default.aspx"); } else if (e.CommandName.ToString() == "dislike") { BOOKGRAMEntities db = new BOOKGRAMEntities(); int postId; String id; id = e.CommandArgument.ToString(); postId = Convert.ToInt32(id); Post te = (from x in db.Post where x.PostId == postId select x).SingleOrDefault(); te.Dislike_num++; db.SaveChanges(); Response.Redirect("Default.aspx"); } else if (e.CommandName.ToString() == "comment") { Session["postId"] = e.CommandArgument.ToString(); Response.Redirect("CommentPage.aspx"); } }