Ejemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            var userId = this.User.Identity.GetUserId();

            var post = this.writerPosts
                       .GetPostById(id)
                       .FirstOrDefault();

            if (userId == post.AuthorId)
            {
                var editPostViewModel = new WriterEditPostViewModel
                {
                    Title      = post.Title,
                    Content    = post.Content,
                    CategoryId = post.CategoryId,
                    UrlVideo   = post.UrlVideo
                };

                ViewBag.SelectedItem = populator.GetSelectedCategories();

                return(View(editPostViewModel));
            }

            this.TempData["Message"] = string.Format(GlobalConstants.FailMessage, "! This not your post!");

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var post = this.adminPosts
                       .GetPostById(id)
                       .FirstOrDefault();

            var editPostViewModel = new AdminEditPostViewModel
            {
                Title      = post.Title,
                Content    = post.Content,
                CategoryId = post.CategoryId,
                Status     = post.Status,
                UrlVideo   = post.UrlVideo
            };

            ViewBag.SelectedItem = populator.GetSelectedCategories();

            return(View(editPostViewModel));
        }