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); }
public IHttpActionResult Add([FromBody] AuthorApiModel authorApiModel) { var authorModel = _mapper.Map <AuthorModel>(authorApiModel); _authorService.Add(authorModel); return(Ok()); }