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); }
public BlogCategory MapToBlogCategory(BlogCategoryEntity model) { var result = new BlogCategory() { ID = model.Id, Name = model.Data.Name, Icon = ResolveAssetURL(model.Data.Icons.FirstOrDefault()) }; return(result); }
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); }