public static void unShare(ShareBO objClass) { MongoCollection <Share> objCollection = db.GetCollection <Share>("c_Share"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.FindAndRemove(query, SortBy.Ascending("_id")); }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["TempUserId"] == null) { userid = Session["UserId"].ToString(); Session["TempUserId"] = null; } else { userid = Session["TempUserId"].ToString(); } atid = Session["EmailPostID"].ToString(); } catch (Exception ex) { Response.Redirect("../../Default.aspx"); } if (Request.QueryString.Count != 0) { post = Request.QueryString.Get(0); } UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); ShareBO objClass = new ShareBO(); objClass.AtId = post; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; WallBO wall = WallBLL.getWallByWallId(objClass.AtId); string p = txtUpdatePost.Text + " <br/>" + wall.Post; PostPreviewLinkButton.Text = p; int type = Convert.ToInt32(Session["PostType"]); if (type == Global.PHOTO || type == Global.TAG_PHOTO) { ImagePreview.ImageUrl = "../../Resources/UserPhotos/" + Session["EmbedPost"].ToString() + ".jpg"; } if (type == Global.POST_VIDEOLINK) { ImagePreview.ImageUrl = Session["EmbedPost"].ToString(); } ((Label)Master.FindControl("lblTitle")).Text = "Share Post"; }
// To share a post protected void ShareLinkButton_Click(object sender, EventArgs e) { GridViewRow row = ((GridViewRow)((LinkButton)sender).NamingContainer); LinkButton linkShare = (LinkButton)row.FindControl("ShareLinkButton"); Label labelShare = (Label)row.FindControl("ShareLabel"); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldId"); if (linkShare.Text == "Share") { // UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); ShareBO objClass = new ShareBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; ShareBLL.insertShare(objClass); //////////////////////////////////////////////////////////////////////////// // Put "follow" record for each user that has been tagged, traverse the list FollowPostBO objFollow = new FollowPostBO(); objFollow.AtId = hfId.Value; objFollow.Type = Global.WALL; objFollow.UserId = Session["hello"].ToString(); objFollow.FirstName = objUser.FirstName; objFollow.LastName = objUser.LastName; FollowPostBLL.insertFollowPost(objFollow); //////////////////////////////////////////////////////////////////////////// labelShare.Text = "You have shared this."; WallBO wall = WallBLL.getWallByWallId(objClass.AtId); string p = ShareDescriptionTextBox.Text + " <br/>" + wall.Post; ShareStatus(p); } else { LikesBO objClass = new LikesBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); LikesBLL.unLikes(objClass); labelShare.Text = ""; linkShare.Text = "Like"; } LoadWall(50); }
public static void updateShare(ShareBO objClass) { MongoCollection <Share> objCollection = db.GetCollection <Share>("c_Share"); var query = Query.EQ("_id", ObjectId.Parse(objClass.Id)); var sortBy = SortBy.Descending("_id"); var update = Update.Set("UserId", ObjectId.Parse(objClass.UserId)) .Set("AtId", ObjectId.Parse(objClass.AtId)) .Set("Type", objClass.Type) .Set("FirstName", objClass.FirstName) .Set("LastName", objClass.LastName) ; var result = objCollection.FindAndModify(query, sortBy, update, true); }
public static ShareBO getShareByShareId(string Id) { MongoCollection <Share> objCollection = db.GetCollection <Share>("c_Share"); ShareBO objClass = new ShareBO(); foreach (Share item in objCollection.Find(Query.EQ("_id", ObjectId.Parse(Id)))) { objClass.Id = item._id.ToString(); objClass.UserId = item.UserId.ToString(); objClass.AtId = item.AtId.ToString(); objClass.Type = item.Type; objClass.FirstName = item.FirstName; objClass.LastName = item.LastName; break; } return(objClass); }
protected void btnPost_Click(object sender, EventArgs e) { if (post != null) { UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); ShareBO objClass = new ShareBO(); objClass.AtId = post; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; WallBO wall = WallBLL.getWallByWallId(objClass.AtId); string p = txtUpdatePost.Text + " <br/>" + wall.Post; ShareStatus(p); foreach (string item in lstTag) { WallBO objWall2 = new WallBO(); string tagpost = p + "<br/><br/> Tag by <a href=\"ViewProfile.aspx?UserId=" + Session["UserId"].ToString() + "\">" + objUser.FirstName + " " + objUser.LastName + "</a>."; UserBO objUser2 = new UserBO(); objUser2 = UserBLL.getUserByUserId(item); objWall2.PostedByUserId = item; objWall2.WallOwnerUserId = item; objWall2.FirstName = objUser2.FirstName; objWall2.LastName = objUser2.LastName; objWall2.Post = tagpost; objWall2.AddedDate = DateTime.Now; objWall2.Type = Convert.ToInt32(Session["PostType"]); objWall2.EmbedPost = Session["EmbedPost"].ToString(); RWallPost(" tag post to <a href=\"ViewProfile.aspx?UserId=" + item + "\">" + objUser2.FirstName + " " + objUser2.LastName + "</a>"); WallBLL.insertWall(objWall2); } ShareBLL.insertShare(objClass); RWallPost(" Share a Post"); Response.Redirect("UserData.aspx"); } }
public static bool youShare(ShareBO objClass) { MongoCollection <BsonDocument> objCollection = db.GetCollection <BsonDocument>("c_Share"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.Find(query); if (result.Any()) { return(true); } else { return(false); } }
// To share a post protected void ShareLinkButton_Click(object sender, EventArgs e) { GridViewRow row = ((GridViewRow)((LinkButton)sender).NamingContainer); LinkButton linkShare = (LinkButton)row.FindControl("ShareLinkButton"); Label labelShare = (Label)row.FindControl("ShareLabel"); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldId"); Session["PostID"] = hfId; if (linkShare.Text == "Share") { // Getting the user information UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); // Creating Share object ShareBO objClass = new ShareBO(); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; // Getting the post which is going to be shared WallBO wall = WallBLL.getWallByWallId(objClass.AtId); string p = txtUpdatePost.Text + " <br/>" + wall.Post; // Sharing the post on the wall ShareStatus(p); // Registering the Share after successful completion of the above process ShareBLL.insertShare(objClass); } LoadWall(50); }
public static void insertShare(ShareBO objClass) { MongoCollection <BsonDocument> objCollection = db.GetCollection <BsonDocument>("c_Share"); var query = Query.And( Query.EQ("Type", objClass.Type), Query.EQ("AtId", ObjectId.Parse(objClass.AtId)), Query.EQ("UserId", ObjectId.Parse(objClass.UserId))); var result = objCollection.Find(query); if (!result.Any()) { BsonDocument doc = new BsonDocument { { "UserId", ObjectId.Parse(objClass.UserId) }, { "AtId", ObjectId.Parse(objClass.AtId) }, { "Type", objClass.Type }, { "FirstName", objClass.FirstName }, { "LastName", objClass.LastName }, { "AddedDate", DateTime.Now }, }; var rt = objCollection.Insert(doc); } }
public static bool youShare(ShareBO objClass) { return(ShareDAL.youShare(objClass)); }
public static void unShare(ShareBO objClass) { ShareDAL.unShare(objClass); }
public static void updateShare(ShareBO objShare) { ShareDAL.updateShare(objShare); }
public static void insertShare(ShareBO objShare) { ShareDAL.insertShare(objShare); }