示例#1
0
        public JsonResult DeleteCaption(Guid Id)
        {
            var caption = db.Captions.Find(Id);

            if (caption != null)
            {
                db.Captions.Remove(caption);
                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, "DeleteCaption", vm);
            var result = new
            {
                Data    = str,
                Success = true
            };

            return(Json(result));
        }
        public ActionResult Index()
        {
            var vm = new CaptionListViewModel
            {
                CurrentPageNumber = 1,
                Captions          = new List <CaptionViewModel>()
            };


            return(View(vm));
        }
        /// <summary>
        /// The list page that should be appended to the main-content of the page
        /// </summary>
        /// <returns></returns>
        public ActionResult List()
        {
            Int32.TryParse(Request.Params["page"], out var pageNumber);
            var vm = new CaptionListViewModel
            {
                CurrentPageNumber = pageNumber + 1,
                Captions          = Search(pageNumber)
            };

            vm.EndOfSearch = Search(pageNumber + 1).Count == 0;
            return(PartialView(vm));
        }
示例#4
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));
        }
示例#5
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));
        }