// GET: PostEditor public ActionResult CreatePost() { PostService PostService = new PostService(User.Identity.GetUserId()); PostEditVm model = PostService.GetPostEditVm(); IList<IContentType> Contents = Session["PostContents"] as IList<IContentType>; if (Contents != null) { model.PostContents = Contents; } return View("EditPost", model); }
public ActionResult EditPost(int PostId) { Post Model = (from a in _unitOfWork.db.Posts where a.PostId == PostId select a) .SingleOrDefault(); PostService PostService = new PostService(Model); PostEditVm retModel = PostService.GetPostEditVm(); IList<IContentType> Contents = Session["PostContents"] as IList<IContentType>; if (Contents == null) { Contents = new List<IContentType>(); } Contents = retModel.PostContents; Session["PostContents"] = Contents; //IList<IContentType> Contents2 = Session["PostContents"] as IList<IContentType>; //var Contents3 = Session["PostContents"]; //IList<IContentType> Contents4 = Contents3 as IList<IContentType>; return View("EditPost", retModel); }