private void HandleInclude(ArticleWithIncludeDto dto, string include) { if (!string.IsNullOrEmpty(include)) { var entityIncludes = include.AnalyzeInclude(); foreach (var entity in entityIncludes) { switch (entity) { case "category": dto.Category = Mapper.Map <CategoryRefDto>(_categoryDomainService.Get(dto.CategoryId)); break; case "author": dto.Author = Mapper.Map <AgentRefDto>(_agentDomainService.Get(dto.AuthorId)); break; case "tags": dto.Tags = dto.TagIds.Select(id => Mapper.Map <TagRefDto>(_tagDomainService.Get(id))); break; default: throw new Exception("Invalid include parameters."); } } } }
public TagDto AddTag(ArticleTagRelationDto input) { _articleTagRelationDomainService.Add(input.MapTo <ArticleTagRelationBase>()); var t = _tagDomainService.Get(input.TagId); return(Mapper.Map <TagDto>(t)); }
public TagDto Get(int tagId) { return Mapper.Map<TagDto>(_tagDomainService.Get(tagId)); }