Exemplo n.º 1
0
        public async Task <IActionResult> CreateBlogPost(BlogPost blogPost)
        {
            var user = await userManager.GetUserAsync(User);

            _logger.LogInformation("User:{0} requested creation of blogpost:{1}", user.UserName, blogPost);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            BlogPostBase createdBlogPost = null;

            switch (blogPost.Category)
            {
            case SportBlogPost.Category:
                createdBlogPost = await blogPostService.CreateBlogPost(new SportBlogPost());

                break;

            case ChildBlogPost.Category:
                createdBlogPost = await blogPostService.CreateBlogPost(new ChildBlogPost());

                break;

            case PublicLifeBlogPost.Category:
                createdBlogPost = await blogPostService.CreateBlogPost(new PublicLifeBlogPost());

                break;

            default:
                BadRequest("Selected category does not exist.");
                break;
            }
            return(Ok(createdBlogPost));
        }
Exemplo n.º 2
0
        public CommentTests()
        {
            var parentComment = new Comment
            {
                OwnerPostId = Guid.Parse(InMemoryBlogPostRepository.SportBlogPostId),
                Content     = "Ez a messi milyen messire lõtte a labdát exdí",
                Id          = Guid.NewGuid(),
            };
            var parentCommentChild = new Comment
            {
                OwnerPostId = Guid.Parse(InMemoryBlogPostRepository.SportBlogPostId),
                Content     = "ja sztem is",
                Id          = Guid.NewGuid(),
                Parent      = parentComment
            };

            comments = new List <Comment>
            {
                parentComment,
                parentCommentChild,
                new Comment
                {
                    OwnerPostId = Guid.Parse(InMemoryBlogPostRepository.SportBlogPostId),
                    Content     = "sztem meg nem gyere beszéljük meg",
                    Id          = Guid.NewGuid(),
                    Parent      = parentCommentChild,
                },
            };
            blogpost = new SportBlogPost
            {
                Content         = "Valami sportos vmi",
                CreatedOn       = DateTime.Now,
                Id              = Guid.Parse(InMemoryBlogPostRepository.SportBlogPostId),
                Title           = "Sportos title",
                Comments        = comments,
                BackgroundImage = new Image
                {
                    ImagePath = new Uri("img/InMemory/SportBlogPic.jpg", UriKind.Relative)
                }
            };
        }
Exemplo n.º 3
0
        protected static bool HasBlogPostBaseAllFieldValues(BlogPostBase postBase)
        {
            if (postBase == null)
            {
                return false;
            }

            bool hasFieldValues = (postBase.BlavenId != null) && (postBase.BlogKey != null) && (postBase.Hash != null)
                                  && (postBase.SourceId != null);
            return hasFieldValues;
        }