Exemple #1
0
        public ActionResult DeletePost(Guid Id)
        {
            var post = db.Posts.Find(Id);

            if (post != null)
            {
                db.Posts.Remove(post);
                db.SaveChanges();
            }

            // return success
            var list = new List <PostViewModel>();

            DataContextService.ApplyEntitySorting(db.Posts.ToList()).ForEach(c => list.Add(new PostViewModel(c)));

            var vm = new PostListViewModel
            {
                Posts = list
            };
            var str    = RenderPartialToStringExtensions.RenderPartialToString(ControllerContext, "DeletePost", vm);
            var result = new
            {
                Data    = str,
                Success = true
            };

            return(Json(result));
        }
Exemple #2
0
        /// <summary>
        /// Delete Post View
        /// </summary>
        /// <returns></returns>
        public ActionResult DeletePost()
        {
            var list = new List <PostViewModel>();

            DataContextService.ApplyEntitySorting(db.Posts.ToList()).ForEach(c => list.Add(new PostViewModel(c)));

            var vm = new PostListViewModel
            {
                Posts = list
            };

            return(PartialView("DeletePost", vm));
        }
Exemple #3
0
        /// <summary>
        /// Delete Caption View
        /// </summary>
        /// <returns></returns>
        public ActionResult DeleteCaption()
        {
            var list = new List <CaptionViewModel>();

            DataContextService.ApplyEntitySorting(db.Captions.ToList()).ForEach(c => list.Add(new CaptionViewModel(c)));

            var vm = new CaptionListViewModel
            {
                Captions = list
            };

            return(PartialView("DeleteCaption", vm));
        }
Exemple #4
0
        public ActionResult CreatePost(string title, string content, Guid[] id)
        {
            var post = new Post
            {
                PostTitle   = title,
                PostContent = content,
                PostedBy    = SecurityService.GetLoggedInUser().Name,
                Captions    = new List <Caption>()
            };

            if (id != null)
            {
                foreach (var capId in id)
                {
                    var cap = db.Captions.Find(capId);
                    if (cap != null)
                    {
                        post.Captions.Add(cap);
                    }
                }
            }

            db.Posts.Add(post);
            db.SaveChanges();

            // return success
            var list = new List <CaptionViewModel>();

            DataContextService.ApplyEntitySorting(db.Captions.ToList()).ForEach(c => list.Add(new CaptionViewModel(c)));

            var vm = new CaptionListViewModel
            {
                Captions = list
            };
            var str    = RenderPartialToStringExtensions.RenderPartialToString(ControllerContext, "CreatePost", vm);
            var result = new
            {
                Data    = str,
                Success = true
            };

            return(Json(result));
        }