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