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);
        }
Beispiel #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;
        }
Beispiel #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
                };
 }
Beispiel #5
0
 public void CreatePost(PostInput postInput)
 {
     postInput.PostedOn = DateTime.Now;
     var post = _mapper.MapPostInputToNewEntity(postInput);
     _postsRepository.Insert(post);
 }
Beispiel #6
0
        public void UpdatePost(PostInput postInput)
        {
            postInput.Modified = DateTime.Now;

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

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