public ActionResult AddPost(AddPostForm addPostForm) { addPostForm.TagIds = addPostForm.TagIds ?? new List <int>(); if (ModelState.IsValid) { var post = Mapper.Map <Post>(addPostForm); postRepository.AddOrUpdate(post); return(RedirectToAction("Posts", "Blog")); } else { addPostForm.Categories = categoryRepository.GetAll().ToList(); addPostForm.Tags = tagRepository.GetAll().ToList(); return(View(addPostForm)); } }