示例#1
0
        public static TModel FromArticle <TModel>(Article article) where
        TModel : ArticleApiModel, new()
        {
            var model = new TModel();

            model.Id = article.Id;

            model.AuthorId = article.AuthorId;

            model.Slug = article.Slug;

            model.FeaturedImageUrl = article.FeaturedImageUrl;

            model.Title = article.Title;

            model.HtmlContent = article.HtmlContent;

            model.Published = article.Published;

            model.IsPublished = article.IsPublished;

            model.Author = AuthorApiModel.FromAuthor(article.Author);

            model.Tags = article.Tags.Select(t => TagApiModel.FromTag(t)).ToList();

            model.Categories = article.Categories.Select(c => CategoryApiModel.FromCategory(c)).ToList();

            return(model);
        }
示例#2
0
        public IHttpActionResult Add([FromBody] AuthorApiModel authorApiModel)
        {
            var authorModel = _mapper.Map <AuthorModel>(authorApiModel);

            _authorService.Add(authorModel);
            return(Ok());
        }