public static IQueryable <IBlogPost> GetBlogPosts(MyIBL ibl)
 {
     lock (typeof(CacheController))
     {
         IQueryable <IBlogPost> blogPosts = (IQueryable <IBlogPost>)HttpRuntime.Cache["BlogPosts"];
         if (blogPosts == null)
         {
             blogPosts = ibl.GetPostList();
             HttpRuntime.Cache.Insert("BlogPosts", blogPosts);
         }
         return(blogPosts);
     }
 }
Exemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            bool isDeleted = false;

            if (_bl.GetPostList().Any(item => item.ID == id))
            {
                _bl.DeletePost(_bl.GetPost(id));
                _bl.SaveChanges();

                // In Order to execute UEB4 Init Test correctly isDeleted is set to true after user gets deleted
                // otherwise i would check with the method GetDeletedUserList if user is really set to isDeleted=true.
                isDeleted = true;
            }

            //isDeleted = _bl.GetDeletedPostList().Any(item => item.ID == id);

            CacheController.UpdateBlogPosts(_bl);

            return(Json(new
            {
                Success = isDeleted,
                Message = isDeleted ? "Successfully deleted BlogPost" : "There was a problem deleting the BlogPost"
            }, JsonRequestBehavior.AllowGet));
        }
        public static void UpdateBlogPosts(MyIBL ibl)
        {
            IQueryable <IBlogPost> blogPosts = ibl.GetPostList();

            HttpRuntime.Cache.Insert("BlogPosts", blogPosts);
        }