Inheritance: IEntity
 public EventViewModel CreateEventViewModel(News news)
 {
     return new EventViewModel
                {
                    ProjectId = news.HumanTaskHistory.Task.ProjectId,
                    ProjectName = news.HumanTaskHistory.Task.Project.Name,
                    TaskName = news.HumanTaskHistory.NewName,
                    WhoChangeUserName = userProcessor.GetUser(news.HumanTaskHistory.UserId).UserName,
                    WhoChangeUserId = news.HumanTaskHistory.UserId,
                    Action = news.HumanTaskHistory.Action,
                    NewsId = news.Id,
                    TimeAgo = TakeTimeAgo(news.HumanTaskHistory.ChangeDateTime),
                    Details =
                        news.HumanTaskHistory.NewDescription == null
                            ? ""
                            : news.HumanTaskHistory.NewDescription.Length>26 ? news.HumanTaskHistory.NewDescription.Substring(0, 25) + "..."
                            :"",
                   IsRead = news.IsRead,
                   WhoAssigneUserId = news.HumanTaskHistory.NewAssigneeId,
                   WhoAssigneUserName = news.HumanTaskHistory.NewAssigneeId.HasValue ? userProcessor.GetUser(news.HumanTaskHistory.NewAssigneeId.Value).UserName : "",
                   ContainerClassName = news.IsRead ? "container evnt_read" : "container evnt_unread",
                   TaskLinkDetails = "/Project/Details/"+ news.HumanTaskHistory.TaskId,
                    WhoAssigneLinkDetails = "/Project/UserDetails?userId=" + news.HumanTaskHistory.NewAssigneeId,
                    WhoChangeLinkDetails = "/Project/UserDetails?userId=" + news.HumanTaskHistory.UserId,
                    ProjectLinkDetails = "/Project/Project/"+news.HumanTaskHistory.Task.ProjectId ,
                    IsMove = news.HumanTaskHistory.Action == ChangeHistoryTypes.Move ? true : false,
                    IsAssigne = news.HumanTaskHistory.NewAssigneeId.HasValue,
                    IsVisible = true,
                   };
 }
 public void AddNews(HumanTaskHistory taskHistory, User user)
 {
     var news = new News
                    {
                        HumanTaskHistory = taskHistory,
                        IsRead = false,
                        User = user,
                        UserId = user.Id,
                        HumanTaskHistoryId = taskHistory.Id,
                    };
     this.AddNews(news);
 }
        public void Should_AddNews_WithNewsAsParametr()
        {
            // arrange
            News news = new News
            {
                Id = 1,
                UserId = 1
            };

            // act
            this.newsProcessor.AddNews(news);

            // assert
            this.newsRepositoryMock.Verify(mock => mock.AddNews(news), Times.AtLeastOnce());
        }
        public void Should_BroadcastNewsViaNotifier_WhenAddNews()
        {
            // arrange
            News news = new News
                            {
                                Id = 1,
                                UserId = 1
                            };

            // act
            this.newsProcessor.AddNews(news);

            // assert
            this.notifierMock.Verify(mock => mock.BroadcastNews(news), Times.AtLeastOnce());
        }
        public void Should_AddCorrectNews_WithHumanTaskHistoryAsParametr()
        {
            // arrange 
            User user = new User
                            {
                                UserName = "******",
                                Id = 2
                            };
            HumanTaskHistory taskHistory = new HumanTaskHistory
                                               {
                                                   Id = 1,
                                                   Action = "Create",
                                               };
            News news = new News
                            {
                                HumanTaskHistory = taskHistory,
                                HumanTaskHistoryId = taskHistory.Id,
                                Id = 1,
                                IsRead = false,
                                User = user,
                                UserId = user.Id
                            };
            // act

            this.newsProcessor.AddNews(taskHistory, user);

            // assert
            this.newsRepositoryMock.Verify(mock => mock.AddNews(It.Is<News>(x => 
                x.HumanTaskHistoryId == taskHistory.Id
                && x.UserId == user.Id
                && x.User == user
                && x.HumanTaskHistory == taskHistory)), 
                Times.Once());
        }
 public void AddNews(News news)
 {
     this.newsRepository.AddNews(news);
     this.notifier.BroadcastNews(news);
 }
 public void AddNews(News news)
 {
     this.dataBaseContext.Entry(news).State = EntityState.Added;
     this.dataBaseContext.SaveChanges();
 }