public ActionResult CreatePost(PostInput postInput)
        {
            if (!ModelState.IsValid)
            {
                postInput.AvailableCategories = GetAvailableCategories(postInput.CategoryId);
                postInput.AvailableTags = GetAvailableTags();

                return View("CreatePost", postInput);
            }

            _adminService.CreatePost(postInput);

            return RedirectToAction("ManagePosts");
        }
        public ViewResult CreatePost()
        {
            var postInput = new PostInput
                            {
                                AvailableCategories = GetAvailableCategories(),
                                AvailableTags = _adminService.GetTagsForSelectList().Select(t => new SelectListItem
                                {
                                    Text = t.Name,
                                    Value = t.TagId.ToString(CultureInfo.InvariantCulture)
                                })
                            };

            return View("CreatePost", postInput);
        }
Exemple #3
0
        public Post MapPostInputToExistingEntity(PostInput postInput, Post postEntityToUpdate)
        {
            postEntityToUpdate.Category = MapCategory(postInput.CategoryId);
            postEntityToUpdate.Description = postInput.Description;
            postEntityToUpdate.Meta = postInput.Meta;
            postEntityToUpdate.Modified = postInput.Modified;
            postEntityToUpdate.PostedOn = postInput.PostedOn;
            postEntityToUpdate.Published = postInput.Published;
            postEntityToUpdate.ShortDescription = postInput.ShortDescription;
            postEntityToUpdate.Tags = MapTags(postInput.TagsIds);
            postEntityToUpdate.Title = postInput.Title;
            postEntityToUpdate.UrlSlug = postInput.UrlSlug;

            return postEntityToUpdate;
        }
Exemple #4
0
 public Post MapPostInputToNewEntity(PostInput postInput)
 {
     return new Post
                {
                    Category = MapCategory(postInput.CategoryId),
                    Description = postInput.Description,
                    Meta = postInput.Meta,
                    Modified = postInput.Modified,
                    PostedOn = postInput.PostedOn,
                    Published = postInput.Published,
                    ShortDescription = postInput.ShortDescription,
                    Tags = MapTags(postInput.TagsIds),
                    Title = postInput.Title,
                    UrlSlug = postInput.UrlSlug
                };
 }
 public void CreatePost(PostInput postInput)
 {
     postInput.PostedOn = DateTime.Now;
     var post = _mapper.MapPostInputToNewEntity(postInput);
     _postsRepository.Insert(post);
 }
        public void UpdatePost(PostInput postInput)
        {
            postInput.Modified = DateTime.Now;

            var postEntityToUpdate = _postsRepository.GetById(postInput.PostId);

            var post = _mapper.MapPostInputToExistingEntity(postInput, postEntityToUpdate);
            _postsRepository.Update(post);
        }