public ActionResult CreatePost(InputPostViewModel model) { if (!ModelState.IsValid) { var categories = m_Categories.GetAllCategories().To <CategoriesViewModel>().ToList(); model.Categories = categories; return(View(model)); } var tags = m_Tags.CheckExist(model.Tags).ToList(); var userId = User.Identity.GetUserId(); var post = new Post { CategoryId = model.CategoryId, Content = model.Content, Tags = tags, Title = model.Title, UserId = userId }; m_Posts.CreatePost(post); TempData["Notification"] = "You successfully add your post."; return(RedirectToAction("Index")); }