public IHttpActionResult Get(int id) { CommentServices commentServices = CreateCommentServices(); var comment = commentServices.GetCommentById(id); return(Ok(comment)); }
public void AddComment_ShouldAdd() { var videoRepositoryMock = new Mock <IRepository <Video> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var commentRepositoryMock = new Mock <IRepository <Comment> >(); var userRepositoryMock = new Mock <IRepository <VidconfileUser> >(); Comment value = null; commentRepositoryMock.Setup(x => x.Add(It.IsAny <Comment>())) .Callback <Comment>(x => value = x); CommentServices commentService = new CommentServices(commentRepositoryMock.Object, unitOfWorkMock.Object, userRepositoryMock.Object, videoRepositoryMock.Object); Video video = new Video(); VidconfileUser user = new VidconfileUser(); string commentText = "asdasd"; commentService.AddComment(video, user, commentText); Assert.Same(video, value.Video); Assert.Same(user, value.Author); Assert.Same(commentText, value.CommentText); commentRepositoryMock.Verify(x => x.Add(value), Times.Once); unitOfWorkMock.Verify(x => x.Commit(), Times.Once); }
private CommentServices CreateCommentService() { var authorId = Guid.Parse(User.Identity.GetUserId()); var CommentService = new CommentServices(authorId); return(CommentService); }
private CommentServices CreateCommentService() { var userId = Guid.Parse(User.Identity.GetUserId()); var commentService = new CommentServices(userId); return(commentService); }
private void LoadComments() { var list = new CommentServices().GetCommentsForReview(CurrentProfile.ID, CurrentReview.StartDate, CurrentReview.DueDate).OrderByDescending(o => o.DateCreated); switch (((Person)SecurityContextManager.Current.CurrentUser).RoleID) { case (int)SecurityRole.ADMIN: case (int)SecurityRole.EXECUTIVE_MANAGEMENT: case (int)SecurityRole.MANAGER: dlComments.DataSource = list; dlComments.DataBind(); break; case (int)SecurityRole.EMPLOYEE: if (SecurityContextManager.Current.CurrentUser.ID == CurrentProfile.ID) { dlComments.DataSource = list; dlComments.DataBind(); } break; } if (list.Count() > 0) { rtsReview.Tabs.FindTabByValue("4").Text = ""; rtsReview.Tabs.FindTabByValue("4").Text += "comments (" + list.Count().ToString() + ")"; } }
public IHttpActionResult Get(int postId) { CommentServices commentService = CreateCommentService(); var comment = commentService.GetCommentByPostId(postId); return(Ok(comment)); }
private CommentServices CreateCommentServices() { var userId = Guid.Parse(User.Identity.GetUserId()); // shouldn't this be Post Id?? comments are being made to the post... var commentServices = new CommentServices(userId); return(commentServices); }
protected void ReportPostClicked(object o, EventArgs e) { if (SecurityContextManager.Current.CurrentURL.Contains("Flagged")) { var c = new CommentServices().GetByID(Convert.ToInt16(((LinkButton)o).Attributes["postid"])); c.FlaggedAsInappropriate = false; new CommentServices().Save(c); } else { var c = new CommentServices().GetByID(Convert.ToInt16(((LinkButton)o).Attributes["postid"])); c.FlaggedAsInappropriate = true; new CommentServices().Save(c); IdeaSeed.Core.Data.NHibernate.NHibernateSessionManager.Instance.CloseSession(); var nc = new CommentServices().GetByID(c.ID); var emails = ""; foreach (var nu in new NotificationSubscriberServices().GetByNotificationIDAccountID((int)Notification.FLAGGED_COMMENT, SecurityContextManager.Current.CurrentAccount.ID)) { emails += nu.Subscriber.Email + ","; } EmailHelper.SendFlaggedCommentNotification(nc, emails.Remove(emails.Length - 1, 1)); } _cache.Remove(SecurityContextManager .Current .CurrentUser.ID.ToString() + "_CommentsFeed"); LoadComments(); }
public async Task CreateValidComment() { //Arrange var options = Utilities.GetOptions(nameof(CreateValidComment)); var idComment = Guid.NewGuid(); var idUser = Guid.NewGuid(); var createdOn = DateTime.UtcNow; var comment = new Comment() { Id = idComment, UserId = idUser, CommentText = "TestCommentText", Author = "testAuthor", CreatedOn = createdOn }; //Assert using (var assertContext = new TheatreContext(options)) { var sut = new CommentServices(assertContext); var result = await sut.CreateCommentAsync(comment); Assert.IsInstanceOfType(result, typeof(Comment)); Assert.AreEqual(idComment, result.Id); Assert.AreEqual(idUser, result.UserId); Assert.AreEqual(createdOn, result.CreatedOn); Assert.AreEqual("TestCommentText", result.CommentText); Assert.AreEqual("testAuthor", result.Author); } }
public IHttpActionResult Get() { CommentServices noteService = CreateCommentServices(); var notes = noteService.GetComments(); return(Ok(notes)); }
public IHttpActionResult Get() { CommentServices commentService = CreateCommentService(); var comments = commentService.GetComments(); return(Ok(comments)); }
public PostsController(ForumCategoryServices forumCategoryServices, PostServices postServices, CommentServices commentServices, TagServices tagServices, ThemeServices themeServices) { _forumCategriesManager = forumCategoryServices; _postsManager = postServices; _commentsManager = commentServices; _tagsManager = tagServices; _themesManager = themeServices; }
protected void DeleteCommentClicked(object o, EventArgs e) { var c = new CommentServices().GetByID(Convert.ToInt32(((LinkButton)o).Attributes["itemid"])); new CommentServices().Delete(c); _cache.Remove(SecurityContextManager.Current.CurrentUser.ID.ToString() + "_CommentsFeed"); LoadComments(); }
public ForumController(ForumCategoryServices forumCategoryServices, PostServices postServices, CommentServices commentServices, TagServices tagServices, ThemeServices themeServices, ApplicationUserManager userManager) { _forumCategriesManager = forumCategoryServices; _postsManager = postServices; _commentsManager = commentServices; _tagsManager = tagServices; _themesManager = themeServices; _userManager = userManager; }
public IHttpActionResult Delete(int id) { CommentServices services = CreateCommentService(); if (!services.DeleteComment(id)) { return(InternalServerError()); } return(Ok()); }
public string GetCommentListByFilters(string userID) { var list = new CommentServices().GetByEnteredBy(Convert.ToInt16(userID)); string s = ""; foreach (var item in list) { s += "{\"name\":\"" + item.EnteredForRef.FirstName + " " + item.EnteredForRef.LastName + "\",\"commentType\":\"" + item.CommentType.ToString() + "\",\"message\":\"" + item.Message + "\",\"enteredBy\":\"" + item.EnteredByRef.FirstName + " " + item.EnteredByRef.LastName + "\",\"commentDate\":\"" + item.DateCreated.ToShortDateString() + "\"}"; } return(""); }
protected void SaveCommentsClicked(object o, EventArgs e) { foreach (DataListItem row in dlComments.Items) { if (row.ItemType == ListItemType.Item || row.ItemType == ListItemType.AlternatingItem) { var c = new CommentServices().GetByID(Convert.ToInt32(((IdeaSeed.Web.UI.CheckBox)row.FindControl("cbSelected")).Attributes["itemid"])); c.IncludedInReview = ((IdeaSeed.Web.UI.CheckBox)row.FindControl("cbSelected")).Checked; new CommentServices().Save(c); } } }
public async Task CorrectlyDeletedComment() { var options = Utilities.GetOptions(nameof(CorrectlyDeletedComment)); var id = Guid.NewGuid(); var reviewId = Guid.NewGuid(); var userId = Guid.NewGuid(); var createdOn = DateTime.UtcNow; var user = new User { Id = userId, UserName = "******", }; var review = new Review { Id = reviewId, Author = user.UserName }; var comment = new Comment { Id = id, Review = review, ReviewId = reviewId, User = user, UserId = user.Id, CreatedOn = createdOn }; review.Comments.Add(comment); user.Comments.Add(comment); using (var assertContext = new TheatreContext(options)) { await assertContext.Users.AddAsync(user); await assertContext.Reviews.AddAsync(review); await assertContext.Comments.AddAsync(comment); await assertContext.SaveChangesAsync(); var commentServices = new CommentServices(assertContext); var result = await commentServices.DeleteCommentAsync(id, reviewId); } using (var assertContext = new TheatreContext(options)) { var result = await assertContext.Comments.FirstAsync(); Assert.AreEqual(true, result.IsDeleted); } }
static void Main(string[] args) { //Remove database client.DropDatabase("SocialNetworkDb"); //Creates database if not exist var database = GetDatabase("SocialNetworkDb"); CreateSocialNetworkCollections(database); var circleServices = new CircleServices(connectionString); var commentServices = new CommentServices(connectionString); var postServices = new PostServices(connectionString); var userServices = new UserServices(connectionString); var _users = database.GetCollection <User>("Users"); var dd = new DummyData(); dd.InsertDummyData(database, connectionString); while (true) { DisplayMainChoices(); var input = UserInput("Input Selection"); switch (input) { case "1": ListAllUsers(userServices); break; case "2": UserMenu(userServices); break; case "3": postServices.CreatePost(); break; case "4": commentServices.CreateComment(); break; case "5": userServices.CreateUser(); break; default: Console.WriteLine("Wrong input"); break; } } }
public async Task ThrowWhen_ModelPassedIsNull() { //Arrange var options = Utilities.GetOptions(nameof(CreateValidComment)); using (var assertContext = new TheatreContext(options)) { //Act & Assert var sut = new CommentServices(assertContext); await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.CreateCommentAsync(null)); } }
public async Task ReturnCorrectComments() { var options = Utilities.GetOptions(nameof(ReturnCorrectComments)); var id = Guid.NewGuid(); var id02 = Guid.NewGuid(); var reviewId = Guid.NewGuid(); var createdOn = DateTime.UtcNow; var comment = new Comment { Id = id, ReviewId = reviewId, UserId = Guid.NewGuid(), CommentText = "testCommentText", CreatedOn = createdOn }; var comment02 = new Comment { Id = id02, ReviewId = reviewId, UserId = Guid.NewGuid(), CommentText = "testCommentText", CreatedOn = createdOn }; using (var arrangeContext = new TheatreContext(options)) { await arrangeContext.Comments.AddAsync(comment); await arrangeContext.Comments.AddAsync(comment02); await arrangeContext.SaveChangesAsync(); } using (var assertContext = new TheatreContext(options)) { var sut = new CommentServices(assertContext); var result = await sut.GetCommentsAsync(reviewId); Assert.IsInstanceOfType(result, typeof(ICollection <Comment>)); Assert.AreEqual(2, result.Count()); Assert.AreEqual(comment.CommentText, result.First().CommentText); Assert.AreEqual(comment.Id, result.First().Id); Assert.AreEqual(comment02.CommentText, result.Last().CommentText); Assert.AreEqual(comment02.Id, result.Last().Id); } }
protected void ReportPostClicked(object o, EventArgs e) { if (SecurityContextManager.Current.CurrentURL.Contains("Flagged")) { var c = new CommentServices().GetByID(Convert.ToInt16(((LinkButton)o).Attributes["postid"])); c.FlaggedAsInappropriate = false; new CommentServices().Save(c); } else { var c = new CommentServices().GetByID(Convert.ToInt16(((LinkButton)o).Attributes["postid"])); c.FlaggedAsInappropriate = true; new CommentServices().Save(c); IdeaSeed.Core.Data.NHibernate.NHibernateSessionManager.Instance.CloseSession(); var nc = new CommentServices().GetByID(c.ID); var sb = new StringBuilder(); sb.Append(EmailHelper.EmailHTMLStart()); sb.Append("<div class='maincontainer'>"); sb.Append("<h2><span>Comment Flagged As Inappropriate</span></h2>"); sb.Append("<div class='maincontent'>"); sb.Append(SecurityContextManager.Current.CurrentUser.Name); sb.Append(" flagged the following comment as inappropriate.<br /><br />"); sb.Append("Comment ID: "); sb.Append(nc.ID.ToString()); sb.Append("<br />Entered For: "); sb.Append(nc.EnteredForRef.Name); sb.Append("<br />Entered By: "); sb.Append(nc.EnteredByRef.Name); sb.Append("<br />Comment: "); sb.Append(nc.Message); sb.Append("<br />Click here to view: <a href='"); sb.Append(ConfigurationManager.AppSettings["BASEURL"]); sb.Append("/Comments/"); sb.Append(c.ID.ToString()); sb.Append("'>HRRiver.com</a></div></div>"); sb.Append(EmailHelper.EmailHTMLEnd()); try { var list = new NotificationSubscriberServices().GetByNotificationID((int)Notification.FLAGGED_COMMENT); foreach (var sub in list) { IdeaSeed.Core.Mail.EmailUtils.SendEmail(sub.Subscriber.Email, "*****@*****.**", "", "", "A Comment Has Been Flagged", sb.ToString(), false, ""); } } catch (Exception exc) { } } LoadComments(); }
public IHttpActionResult Post(CommentCreate comment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } CommentServices commentService = CreateCommentService(); if (!commentService.CreateComment(comment)) { return(InternalServerError()); } return(Ok()); }
/// <summary> /// Initializes a new instance of the <see cref="StreakServices"/> class. /// </summary> /// <param name="apiKey">The API key.</param> /// <param name="apiBaseUrl">The API base URL.</param> /// <param name="includeRawResponse">if set to <c>true</c> [include raw JSON response from Streak API].</param> public StreakServices(string apiKey, string apiBaseUrl, bool includeRawResponse) { Users = new UserServices(apiKey, apiBaseUrl, includeRawResponse); Pipelines = new PipelineServices(apiKey, apiBaseUrl, includeRawResponse); Boxes = new BoxServices(apiKey, apiBaseUrl, includeRawResponse); Stages = new StageServices(apiKey, apiBaseUrl, includeRawResponse); Fields = new FieldServices(apiKey, apiBaseUrl, includeRawResponse); Tasks = new TaskServices(apiKey, apiBaseUrl, includeRawResponse); Tasks = new TaskServices(apiKey, apiBaseUrl, includeRawResponse); Files = new FileServices(apiKey, apiBaseUrl, includeRawResponse); Threads = new ThreadServices(apiKey, apiBaseUrl, includeRawResponse); Comments = new CommentServices(apiKey, apiBaseUrl, includeRawResponse); Snippets = new SnippetServices(apiKey, apiBaseUrl, includeRawResponse); }
public async Task ThrowWhen_NoCommentFound() { // Arrange var options = Utilities.GetOptions(nameof(ThrowWhen_NoCommentFound)); var id = Guid.NewGuid(); var reviewId = Guid.NewGuid(); using (var assertContext = new TheatreContext(options)) { //Act & Assert var sut = new CommentServices(assertContext); await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.DeleteCommentAsync(id, reviewId)); } }
public JsonResult GetCommentByPhotos([FromQuery(Name = "Id")] int Id) { var commentsResult = new List <Comment>(); try { //Get all comments by photos id commentsResult = CommentServices.GetCommentsByPhotoId(Id); return(Json(new { message = MessagesHelper.TextMsg, type = MessagesHelper.success, commentsResult })); } catch (Exception ex) { return(Json(new { message = MessagesHelper.TextMsg, type = MessagesHelper.warning, commentsResult })); } }
private void SaveComment() { var c = new HRR.Core.Domain.Comment(); c.CategoryID = Convert.ToInt16(ddlCommentCategory.SelectedValue); c.CommentType = Convert.ToInt16(ratingBinary.SelectedItem.Value); c.DateCreated = DateTime.Now; c.EnteredBy = SecurityContextManager.Current.CurrentUser.ID; c.EnteredFor = Convert.ToInt16(ddlCommentFor.SelectedValue); c.FlaggedAsInappropriate = false; c.Message = tbNewComment.Text; c.TeamID = Convert.ToInt16(ddlTeams.SelectedValue); c.FollowUpDate = DateTime.Now.AddDays(7); c.SecurityType = 1; c.AccountID = SecurityContextManager.Current.CurrentAccount.ID; c.LastUpdated = DateTime.Now; c.ChangedBy = SecurityContextManager.Current.CurrentUser.ID; c.IncludedInReview = true; new CommentServices().Save(c); var a = new Activity(); a.AccountID = c.AccountID; a.ActivityType = (int)ActivityType.COMMENT; a.DateCreated = DateTime.Now; a.PerformedBy = c.EnteredBy; a.PerformedFor = c.EnteredFor; a.URL = "/Comments/" + c.ID.ToString(); new ActivityServices().Save(a); IdeaSeed.Core.Data.NHibernate.NHibernateSessionManager.Instance.CloseSession(); var nc = new CommentServices().GetByID(c.ID); if (new TeamMemberServices().GetByPersonIDTeamID(c.EnteredFor, c.TeamID).RecievesNotifications) { EmailHelper.SendNewCommentNotification(nc); } _cache.Remove(SecurityContextManager .Current .CurrentUser.ID.ToString() + "_CommentsFeed"); LoadComments(); }
public HomeController(PropertiesServices propertyServices, UserServices userServices, ReservationServices reservationServices, ReviewServices reviewServices, PostServices postsManager, CommentServices commentsManager, ContactMessageServices contactMessagesManager, CityServices citiesManager) { propertyManager = propertyServices; reservationsManager = reservationServices; reviewsManager = reviewServices; this.postsManager = postsManager; this.commentsManager = commentsManager; this.contactMessagesManager = contactMessagesManager; this.citiesManager = citiesManager; this.userServices = userServices; }
public IList <Comment> GetTeamsComments() { var list = new List <Comment>(); var results = new List <Comment>(); var temp = new List <Comment>(); var temp2 = new List <Comment>(); foreach (var memberships in ((Person)SecurityContextManager.Current.CurrentUser).Memberships) { var team = memberships.TeamRef; bool ismanager = false; list = new CommentServices().GetByTeamID(team.ID).OrderByDescending(o => o.DateCreated).ToList <Comment>(); foreach (var m in team.Members) { if (m.PersonID == SecurityContextManager.Current.CurrentUser.ID) { if (m.IsManager) { ismanager = true; } } } if (!ismanager) { temp = list; temp.RemoveAll(o => (o.CommentType == -1 && o.EnteredBy != SecurityContextManager.Current.CurrentUser.ID)); results.AddRange(temp); temp2 = list; temp2.RemoveAll(o => (o.CommentType == -1 && o.EnteredFor != SecurityContextManager.Current.CurrentUser.ID)); results.AddRange(temp2); } else { results = list; } } return(results); }
public void AddComment_NullVideo_ShouldThrow() { var videoRepositoryMock = new Mock <IRepository <Video> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var commentRepositoryMock = new Mock <IRepository <Comment> >(); var userRepositoryMock = new Mock <IRepository <VidconfileUser> >(); CommentServices commentService = new CommentServices(commentRepositoryMock.Object, unitOfWorkMock.Object, userRepositoryMock.Object, videoRepositoryMock.Object); Video video = new Video(); VidconfileUser user = new VidconfileUser(); string commentText = "asdasd"; string message = Assert .Throws <NullReferenceException>(() => commentService.AddComment(null, user, commentText)) .Message; Assert.Equal("video cannot be null", message); }