public void Load(ShowTeamPostsToggleVisibilityMessage message)
        {
            if (Visibility == false)
            {
                NewestPosts.Clear();

                //load new posts when updated
                var teamLight = facade.ConvertTeamModelToTeamLightModel(message.TeamModel);
                loadedTeam = facade.GetDetail(teamLight) as TeamModel;

                var newestPosts = facade.FindNewestNPostsInTeam(loadedTeam, PostsQuantity)
                                  .ToList();
                NewestPosts.AddRange(newestPosts);

                //sort comments
                foreach (var post in NewestPosts)
                {
                    post.Comments = post.Comments.OrderBy(c => c.Date).ToArray();
                    post.Comments = post.Comments.Take(CommentsQuantity).ToArray();
                }

                loadedTeam = message.TeamModel;
            }
            else
            {
                loadedTeam       = new TeamModel();
                PostsQuantity    = 2;
                CommentsQuantity = 1;
            }

            Visibility = !Visibility;
        }
Пример #2
0
        private void AddNewPost()
        {
            Model.Author            = loggedUser;
            Model.Comments          = new List <CommentModel>();
            Model.CorrespondingTeam = facade.ConvertTeamModelToTeamLightModel(LoadedTeam);
            Model.Date                 = DateTime.Now;
            Model.AssociatedFiles      = new List <ContributionFileLightModel>();
            Model.ContributionUserTags = new List <ContributionUserTagModel>();

            Model = facade.Create(Model) as PostModel;
            facade.SetTaggedUserInPost(this.TaggedUsers, Model);

            mediator.Send(new ShowTeamPostsToggleVisibilityMessage {
                TeamModel = LoadedTeam
            });
            mediator.Send(new PostAddedMessage());
        }