protected void txtComments_TextChanged(object sender, EventArgs e) { GridViewRow row = ((GridViewRow)((TextBox)sender).NamingContainer); TextBox txtcomments = (TextBox)row.FindControl("txtComments"); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldId"); UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); CommentsBO objClass = new CommentsBO(); objClass.MyComments = txtcomments.Text; objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; if (!objClass.MyComments.Equals("")) { CommentsDAL.insertComments(objClass); } ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myScript", "document.getElementById('" + txtcomments.ClientID + "').value = '';", true); GridView gridviewComments = (GridView)row.FindControl("GridViewComments"); gridviewComments.DataSource = CommentsDAL.getCommentsTop(Global.WALL, hfId.Value, 2); gridviewComments.DataBind(); LoadWall(50); }
public void Update(CommentsBO comment) { Comments newComment = AutoMapper <CommentsBO, Comments> .Map(comment); Database.CommentsUowRepository.Update(newComment); Database.Save(); }
public void Create(CommentsBO comment) { Comments newComment = new Comments() { Comment = comment.Comment, UserId = comment.UserId, WorkId = comment.WorkId }; Database.CommentsUowRepository.Create(newComment); Database.Save(); }
protected void InsertComments() { UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Userid); CommentsBO objClass = new CommentsBO(); objClass.MyComments = txtComments.Text; objClass.AtId = Photoid; objClass.Type = Global.PHOTO; objClass.UserId = Userid; objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; if (!objClass.MyComments.Equals("")) { CommentsDAL.insertComments(objClass); } ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myScript", "document.getElementById('" + txtComments.ClientID + "').value = '';", true); List <string> lst = new List <string>(); lst = CommentsDAL.getCommentsUserIdbyAtId(Global.PHOTO, Photoid); LoadDataListComments(); if (Isfollow == true) { foreach (string item in lst) { UserBO objUserNotify = new UserBO(); objUserNotify = UserBLL.getUserByUserId(item); msgtext = "Dear Pyramid Plus user, Comments on your photos. "; NotificationBO objNotify = new NotificationBO(); objNotify.MyNotification = "<a href=\"ViewProfile.aspx?UserId=" + Userid + "\">" + objUser.FirstName + " " + objUser.LastName + "</a> comments on <a href=\"ViewPhoto.aspx?PhotoId=" + Photoid + "\">photo</a>"; objNotify.AtId = Photoid; objNotify.Type = Global.PHOTO; objNotify.UserId = item; objNotify.FirstName = objUserNotify.FirstName; objNotify.LastName = objUserNotify.LastName; objNotify.FriendId = Userid; objNotify.FriendFName = objUser.FirstName; objNotify.FriendLName = objUser.LastName; objNotify.Status = false; // ThreadPool.QueueUserWorkItem(new WaitCallback(sendEmail), (object)objUserNotify.Email); //sendEmail(objUserNotify.Email); NotificationBLL.insertNotification(objNotify); } } }
protected void txtComments_TextChanged(object sender, EventArgs e) { GridViewRow row = ((GridViewRow)((TextBox)sender).NamingContainer); TextBox txtcomments = (TextBox)row.FindControl("txtComments"); HiddenField hfId = (HiddenField)row.FindControl("HiddenFieldWallId"); UserBO objUser = new UserBO(); objUser = UserBLL.getUserByUserId(Session["UserId"].ToString()); CommentsBO objClass = new CommentsBO(); objClass.MyComments = ConvertUrlsToLinks(txtcomments.Text); objClass.AtId = hfId.Value; objClass.Type = Global.WALL; objClass.UserId = Session["UserId"].ToString(); objClass.FirstName = objUser.FirstName; objClass.LastName = objUser.LastName; if (!objClass.MyComments.Equals("")) { CommentsDAL.insertComments(objClass); } ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myScript", "document.getElementById('" + txtcomments.ClientID + "').value = '';", true); GridView gridviewComments = (GridView)row.FindControl("GridViewComments"); gridviewComments.DataSource = CommentsDAL.getCommentsTop(Global.WALL, hfId.Value, 2); gridviewComments.DataBind(); /////////////////////////////////////Friends recent activities if (!userid.Equals(Session["UserId"].ToString())) { UserBO objFUser = new UserBO(); objFUser = UserBLL.getUserByUserId(userid); WallBO objWall = new WallBO(); objWall.PostedByUserId = Session["UserId"].ToString(); objWall.WallOwnerUserId = Session["UserId"].ToString(); objWall.FirstName = objUser.FirstName; objWall.LastName = objUser.LastName; objWall.Post = " Comments on <a href=\"ViewProfile.aspx?UserId=" + userid + "\">" + objFUser.FirstName + " " + objFUser.LastName + "</a> Wall Post"; objWall.AddedDate = DateTime.Now; objWall.Type = Global.PROFILE_CHANGE; WallBLL.insertWall(objWall); } //////////////////////////////////////// }
public void updateComments(CommentsBO objClass) { MongoCollection <Comments> objCollection = db.GetCollection <Comments>("c_Comments"); 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("MyComments", objClass.MyComments) .Set("Type", objClass.Type) .Set("FirstName", objClass.FirstName) .Set("LastName", objClass.LastName) ; var result = objCollection.FindAndModify(query, sortBy, update, true); }
public string insertComments(CommentsBO objClass) { MongoCollection <BsonDocument> objCollection = db.GetCollection <BsonDocument>("c_Comments"); BsonDocument doc = new BsonDocument { { "UserId", ObjectId.Parse(objClass.UserId) }, { "AtId", ObjectId.Parse(objClass.AtId) }, { "MyComments", objClass.MyComments }, { "Type", objClass.Type }, { "FirstName", objClass.FirstName }, { "LastName", objClass.LastName }, { "AddedDate", DateTime.Now }, }; var rt = objCollection.Insert(doc); return(doc["_id"].ToString()); }
public static void updateComments(CommentsBO objClass) { if (objClass.Type == 1) { StrategyContextComment commentobject = new StrategyContextComment(new StrategyConcretePhotoComment()); commentobject.updateComments(objClass); } else if (objClass.Type == 2) { StrategyContextComment commentobject = new StrategyContextComment(new StrategyConcreteVideoComment()); commentobject.updateComments(objClass); } else { StrategyContextComment commentobject = new StrategyContextComment(new StrategyConcreteOtherComment()); commentobject.updateComments(objClass); } }
public static string insertComments(CommentsBO objClass) { if (objClass.Type == 1) { StrategyContextComment commentobject = new StrategyContextComment(new StrategyConcretePhotoComment()); return(commentobject.insertComments(objClass)); } else if (objClass.Type == 2) { StrategyContextComment commentobject = new StrategyContextComment(new StrategyConcreteVideoComment()); return(commentobject.insertComments(objClass)); } else { StrategyContextComment commentobject = new StrategyContextComment(new StrategyConcreteOtherComment()); return(commentobject.insertComments(objClass)); } }
public static CommentsBO getCommentsByCommentsId(string Id) { MongoCollection <Comments> objCollection = db.GetCollection <Comments>("c_Comments"); CommentsBO objClass = new CommentsBO(); foreach (Comments 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.MyComments = item.MyComments; objClass.FirstName = item.FirstName; objClass.LastName = item.LastName; break; } return(objClass); }
public ActionResult Details(WorksViewModel user) { HttpCookie cookieReq = Request.Cookies["My localhost cookie"]; int ids = 0; if (cookieReq != null) { ids = Convert.ToInt32(cookieReq["ids"]); } WorksBO newUser = AutoMapper <WorksViewModel, WorksBO> .Map(user); CommentsBO newComment = new CommentsBO(); newComment.Comment = newUser.Name; newComment.WorkId = newUser.Id; newComment.UserId = ids; return(RedirectToActionPermanent("Index", "Works")); }
public ActionResult GetComments(WorksViewModel work) { HttpCookie cookieReqs = Request.Cookies["My localhost cookie"]; int idsWork = work.Id; int idsUser = 0; if (cookieReqs != null) { idsUser = Convert.ToInt32(cookieReqs["ids"]); } else { FormsAuthentication.SignOut(); } if (work.UserId != 0) { RatingsBO userRatingForWork = ratingServ.GetRatings().Where(x => x.UserId == idsUser && x.WorkId == idsWork).FirstOrDefault(); RatingsBO newRating = new RatingsBO(); newRating.Rank = work.UserId; newRating.UserId = idsUser; newRating.WorkId = idsWork; if (userRatingForWork != null) { RatingsBO old = ratingServ.GetRating(userRatingForWork.Id); ratingServ.DeleteRating(old.Id); ratingServ.Create(newRating); } else { ratingServ.Create(newRating); } } if (work.Name != null) { CommentsBO newComment = new CommentsBO(); newComment.Comment = work.Name; newComment.UserId = idsUser; newComment.WorkId = idsWork; CommentsBO test = commentServ.GetComments().Where(x => x.UserId == idsUser && x.WorkId == idsWork).FirstOrDefault(); if (commentServ.GetComments().Where(x => x.UserId == idsUser && x.WorkId == idsWork).FirstOrDefault() != null) { CommentsBO old = commentServ.GetComment(test.Id); commentServ.DeleteComment(old.Id); commentServ.Create(newComment); } else { commentServ.Create(newComment); } } var commentList = commentServ.GetComments().Join(workServ.GetWorks(), c => c.WorkId, w => w.Id, (c, w) => new { Id = c.Id, Comment = c.Comment, UserId = c.UserId, WorkId = c.WorkId }).Join(userServ.GetUsers(), c => c.UserId, u => u.Id, (c, u) => new InfoModelWithComments { Id = c.Id, UserName = u.Login, Comment = c.Comment, WorkId = c.WorkId, IsDelete = u.IsDelete }).ToList(); foreach (var item in commentList) { if (item.IsDelete == true) { item.UserName = "******"; } } ViewBag.CommentsList = commentList.Where(c => c.WorkId == idsWork).ToList(); List <RatingsBO> lst = ratingServ.GetRatings().Where(x => x.WorkId == idsWork).Join(userServ.GetUsers(), c => c.UserId, u => u.Id, (c, u) => new RatingsBO { Id = c.Id, Rank = c.Rank, UserId = c.UserId, WorkId = c.WorkId, IsDeleteCheck = u.IsDelete }).Where(x => x.IsDeleteCheck == false).ToList(); if (lst.Count != 0) { int sum = 0; int rating = 0; foreach (var item in lst) { sum += item.Rank; } rating = sum / lst.Count; ViewBag.Ratings = rating; } else { ViewBag.Ratings = 0; } return(View("_CommentsTable")); }
public void updateComments(CommentsBO objClass) { strategyInterface.updateComments(objClass); }
//Executes the strategy public string insertComments(CommentsBO objClass) { return(strategyInterface.insertComments(objClass)); }