Exemplo n.º 1
0
        /// <summary>
        /// Comments list
        /// </summary>
        /// <param name="commentType">Comment type</param>
        /// <param name="take">Items to take</param>
        /// <param name="skip">Items to skip</param>
        /// <param name="filter">Filter expression</param>
        /// <param name="order">Sort order</param>
        /// <returns>List of comments</returns>
        public CommentsVM Get()
        {
            if (!Security.IsAuthorizedTo(Rights.ViewPublicComments))
                throw new UnauthorizedAccessException();

            var vm = new CommentsVM();
            var comments = new List<Comment>();
            var items = new List<CommentItem>();

            var all = Security.IsAuthorizedTo(Rights.EditOtherUsersPosts);
            foreach (var p in Post.Posts)
            {
                if (all || p.Author.ToLower() == Security.CurrentUser.Identity.Name.ToLower())
                {
                    comments.AddRange(p.Comments);
                }
            }  
            foreach (var c in comments)
            {
                items.Add(Json.GetComment(c, comments));               
            }
            vm.Items = items;

            vm.Detail = new CommentDetail();
            vm.SelectedItem = new CommentItem();

            return vm;
        }
 public CommentsVM Get()
 {
     var vm = new CommentsVM();
     vm.Items = new List<CommentItem>();
     vm.Items.Add(new CommentItem() { Id = Guid.NewGuid() });
     return vm;
 }