示例#1
0
        public List <BlogIndex> GetIndexData()
        {
            List <BlogIndex> listBlogindex = new List <BlogIndex>();

            foreach (var post in GetAll())
            {
                BlogIndex blogIndex = new BlogIndex();
                blogIndex.Post    = post;
                blogIndex.Billede = billedeFac.GetBy("PostID", post.ID);
                listBlogindex.Add(blogIndex);
            }
            return(listBlogindex);
        }
示例#2
0
        public List <BlogIndex> GetIndexData()
        {
            List <BlogIndex> listBlockIndex = new List <BlogIndex>();

            foreach (var post in GetAll())
            {
                BlogIndex bi = new BlogIndex();
                bi.Post     = post;
                bi.Billeder = bf.GetBy("PostID", post.ID);
                listBlockIndex.Add(bi);
            }
            return(listBlockIndex);
        }
        /// <summary>
        /// Initialise call made by the factory
        /// </summary>
        public override void Initialise()
        {
            // Initialise the users file if there is not already one present in the correct location
            Boolean usersInitialised = InitialiseUsers();

            if (usersInitialised)
            {
                // Check to see if there is an a file containing the index to load to initialise the blog
                try
                {
                    BlogIndex foundIndex = ReadBlogIndex();
                    items             = foundIndex;
                    items.Initialised = true;
                }
                catch (Exception ex)
                {
                    // Could not load error?
                    if (ex.GetType() == typeof(CouldNotLoadBlogException))
                    {
                        // File was not found so create a blank index file
                        if (ex.InnerException != null && ex.InnerException.GetType() == typeof(FileNotFoundException))
                        {
                            // Try and write the blank index
                            try
                            {
                                items = new BlogIndex(); // Generate the new index to be saved
                                if (WriteBlogIndex())
                                {
                                    items.Initialised = true;
                                }
                            }
                            catch (Exception ex2)
                            {
                                throw BlogException.Passthrough(ex, new CouldNotSaveBlogException(ex2)); // Could not do save of the index
                            }
                        }
                    }
                    else
                    {
                        throw BlogException.Passthrough(ex, new CouldNotLoadBlogException(ex)); // Not a handled issue (such as no index so create one)
                    }
                }
            }

            // No item index and not initialised or the users were not initialised then raise an error
            if (!usersInitialised || items == null || !items.Initialised)
            {
                throw new NotInitialisedBlogException();
            }
        }
示例#4
0
        } // End Action Upload

        //
        // GET: /Blog/
        public ActionResult Index()
        {
            BlogIndex bi = new BlogIndex();
            // bi.lsBlogEntries = this.m_dal.GetList<T_BlogPost>(@"");
            string sql = @"
SELECT 
	 T_BlogPost.*
	,ROW_NUMBER() OVER (ORDER BY BP_EntryDate DESC) AS rownum 
FROM T_BlogPost 
ORDER BY BP_EntryDate DESC
" + this.m_fac.PagingTemplate(100);

            using (System.Data.Common.DbConnection con = this.m_fac.Connection)
            {
                bi.lsBlogEntries = con.Query <T_BlogPost>(sql).ToList();
            }

            // UpdateBlogStructure(bi.lsBlogEntries);

            return(View(bi));
        } // End Action Index
示例#5
0
        }         // End Action Upload

        //
        // GET: /Blog/
        public ActionResult Index()
        {
            BlogIndex bi = new BlogIndex();

            // bi.lsBlogEntries = Settings.DAL.GetList<T_BlogPost>(@"");

            using (System.Data.IDbCommand cmd = Settings.DAL.CreateLimitedCommand(@"
SELECT {0} 
	 T_BlogPost.*
	,row_number() OVER (ORDER BY BP_EntryDate DESC) AS rownum 
FROM T_BlogPost 
ORDER BY BP_EntryDate DESC
", 100))
            {
                bi.lsBlogEntries = Settings.DAL.GetList <T_BlogPost> (cmd);
            }


            // UpdateBlogStructure(bi.lsBlogEntries);

            return(View(bi));
        } // End Action Index
        => throw new NotImplementedException();     // Not implemented in the base class

        /// <summary>
        /// Default Constructor
        /// </summary>
        public BlogDataProviderBase()
        {
            // Instantiate the items
            items = new BlogIndex();
            users = new BlogUsers();
        }
示例#7
0
 public BlogController(BlogIndex index)
 {
     _index = index;
 }