Exemple #1
0
        public async Task Update(PostViewModel model)
        {
            var post = mapper.Map <Post>(model);

            post.SetPubDate(model.PubDate);
            foreach (var category in model.GetPostCategories())
            {
                post.AddCategory(category);
            }
            await postRepository.Update(post);
        }
Exemple #2
0
        public async Task <PostViewModel> Add(PostViewModel model)
        {
            var post = new Post
            {
                Title        = model.Title,
                Author       = model.Author,
                Slug         = model.Slug,
                Excerpt      = model.Excerpt,
                Content      = model.Content,
                LastModified = DateTime.UtcNow
            };

            post.SetPubDate(model.PubDate);
            foreach (var category in model.GetPostCategories())
            {
                post.AddCategory(category);
            }
            await postRepository.Add(post);

            return(mapper.Map <PostViewModel>(post));
        }