コード例 #1
0
        public async Task <bool> Handle(CreateCategoryCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                await NotifyValidationErrors(request);

                return(false);
            }

            var entity = new BlogCategoryEntity
            {
                Name = request.Name,
                Slug = request.Slug
            };

            await _blogCategoryRepository.AddAsync(entity);

            if (await Commit())
            {
                await _eventDispatcher.RaiseEvent(new AddCagtegoryEvent { Category = entity });

                return(true);
            }

            return(false);
        }
コード例 #2
0
ファイル: BlogMapper.cs プロジェクト: crazyants/calamari-blog
        public BlogCategory MapToBlogCategory(BlogCategoryEntity model)
        {
            var result = new BlogCategory()
            {
                ID   = model.Id,
                Name = model.Data.Name,
                Icon = ResolveAssetURL(model.Data.Icons.FirstOrDefault())
            };

            return(result);
        }
コード例 #3
0
ファイル: BlogMapper.cs プロジェクト: crazyants/calamari-blog
        public BlogPost MapToBlogPost(BlogPostEntity model, BlogCategoryEntity category, List <BlogPostTagEntity> tags)
        {
            var result = new BlogPost()
            {
                ID            = model.Id,
                PublishedDate = model.Created.Date,
                Title         = model.Data.Title,
                Body          = model.Data.Body,
                Category      = MapToBlogCategory(category),
                Tags          = MapToBlogPostTags(tags)
            };

            return(result);
        }