protected void AddComment_Click(object sender, EventArgs e) { var loggedUserName = this.Context.User.Identity.Name; var commentContent = (this.LoginView.FindControl("AddTextbox") as TextBox).Text; var dateNow = DateTime.Now; var isImportant = true; if (this.Context.User.IsInRole(UserType.Student)) { isImportant = false; } var addNewsEventargs = new AddNewsEventargs() { Username = loggedUserName, Content = commentContent, CreatedOn = dateNow, IsImportant = isImportant }; this.EventAddNews(this, addNewsEventargs); this.CommentsList.DataSource = this.Model.Newsfeed; this.CommentsList.DataBind(); (this.LoginView.FindControl("AddTextbox") as TextBox).Text = string.Empty; }
public void CallAddNewsFromNewsDataService_Once_WithCorrectArguments() { var mockedNewsfeedView = new Mock <INewsfeedView>(); var mockedNewsDataService = new Mock <INewsDataService>(); var newsDataPresenter = new NewsfeedPresenter(mockedNewsfeedView.Object, mockedNewsDataService.Object); var args = new AddNewsEventargs() { Content = It.IsAny <string>(), CreatedOn = It.IsAny <DateTime>(), IsImportant = It.IsAny <bool>(), Username = It.IsAny <string>() }; mockedNewsfeedView.Raise(x => x.EventAddNews += null, args); mockedNewsDataService.Verify(x => x.AddNews(args.Username, args.Content, args.CreatedOn, args.IsImportant), Times.Once()); }
private void AddNews(object sender, AddNewsEventargs e) { this.newsDataService.AddNews(e.Username, e.Content, e.CreatedOn, e.IsImportant); }