示例#1
0
        public Page GetPage(ApplicationEnums.PageEnum page, bool useCache)
        {
            try
            {
                IContentRepository contentRepository = new ContentRepository();
                if (useCache)
                {
                    var pages = GetAllPages();
                    if (pages != null && pages.Count > 0)
                    {
                        var filteredPages = pages.Where(e => e.Name.ToUpper() == page.ToString().ToUpper());
                        if (filteredPages != null && filteredPages.Count() > 0)
                        {
                            return(filteredPages.First());
                        }
                    }
                }

                return(contentRepository.FetchPage(page));
            }
            catch (Exception e)
            {
                throw;
            }
        }
示例#2
0
        public IList <Image> FetchAllImagesForPage(ApplicationEnums.PageEnum page, bool useExistingConnection = false)
        {
            try
            {
                log.Info("[Start - FetchAllImages]");

                StringBuilder query = new StringBuilder();

                query.AppendFormat(@"
                  SELECT [media_id]
                      ,[page_id]
                      ,[image_desc_en]
                      ,[image_desc_fr]
                      ,[image_name]
                      ,[display_order]
                      ,[type]
                  FROM {0}
                WHERE page_id = (select page_id from {1} where name = @name)

                    ", TableMapping.TBL_IMAGE
                                   , TableMapping.TBL_PAGE

                                   );


                List <SqlParameter> parameters = new List <SqlParameter>();
                parameters.Add(CreateParameter("@name", SqlDbType.VarChar, page.ToString(), 20));

                IList <Image> list = new List <Image>();

                if (!useExistingConnection)
                {
                    DBConnect();
                }

                SqlDataReader reader = ReadQuery(query.ToString(), parameters);

                while (reader.Read())
                {
                    Image item = new Image();
                    int   i    = 0;
                    item.MediaId      = ReadInt(ref reader, ref i);
                    item.PageId       = ReadInt(ref reader, ref i);
                    item.ImageDescEn  = ReadString(ref reader, ref i);
                    item.ImageDescFr  = ReadString(ref reader, ref i);
                    item.ImageName    = ReadString(ref reader, ref i);
                    item.DisplayOrder = ReadInt(ref reader, ref i);
                    item.Type         = ReadString(ref reader, ref i);


                    list.Add(item);
                }

                if (!useExistingConnection)
                {
                    DBDisconnect();
                }

                reader.Dispose();

                return(list);
            }
            catch (Exception e)
            {
                log.ErrorFormat("Repository Error {0}", e.ToString());

                throw;
            }
        }
示例#3
0
        private IList <Content> FetchContent(ApplicationEnums.PageEnum page, bool useExistingConnection = false)
        {
            try
            {
                log.Info("[Start]");

                StringBuilder query = new StringBuilder();

                query.AppendFormat(@"
                  SELECT [content_id]
                      ,[page_id]
                      ,[menu_en]
                      ,[menu_fr]
                      ,[title_en]
                      ,[title_fr]
                      ,[content_en]
                      ,[content_fr]
                      ,[type]
                      ,[display_order]
                  FROM {0}
                WHERE page_id = (select page_id from {1} where name = @name)

                    ", TableMapping.TBL_CONTENT
                                   , TableMapping.TBL_PAGE

                                   );


                List <SqlParameter> parameters = new List <SqlParameter>();
                parameters.Add(CreateParameter("@name", SqlDbType.VarChar, page.ToString(), 20));

                IList <Content> list = new List <Content>();
                if (!useExistingConnection)
                {
                    DBConnect();
                }
                SqlDataReader reader = ReadQuery(query.ToString(), parameters);

                while (reader.Read())
                {
                    Content item = new Content();
                    int     i    = 0;
                    item.ContentId = ReadInt(ref reader, ref i);
                    item.PageId    = ReadInt(ref reader, ref i);
                    item.MenuEN    = ReadString(ref reader, ref i);
                    item.MenuFR    = ReadString(ref reader, ref i);
                    item.TitleEN   = ReadString(ref reader, ref i);
                    item.TitleFR   = ReadString(ref reader, ref i);

                    item.ContentEN = ReadString(ref reader, ref i);
                    item.ContentFR = ReadString(ref reader, ref i);



                    item.Type         = ReadString(ref reader, ref i);
                    item.DisplayOrder = ReadInt(ref reader, ref i);

                    list.Add(item);
                }
                reader.Dispose();

                if (!useExistingConnection)
                {
                    DBDisconnect();
                }


                return(list);
            }
            catch (Exception e)
            {
                log.ErrorFormat("Repository Error {0}", e.ToString());

                throw;
            }
        }
示例#4
0
        public Page FetchPage(ApplicationEnums.PageEnum page)
        {
            log.Info("[start]");
            try
            {
                StringBuilder query = new StringBuilder();

                query.AppendFormat(@"
                    SELECT [page_id]
                      ,[name]
                      ,[menu_en]
                      ,[menu_fr]
                      ,[menu_sm_en]
                      ,[menu_sm_fr]
                      ,[title_en]
                      ,[title_fr]
                      ,[type]
                      ,[link_url]
                      ,[display_order]
                  FROM {0}
                    where name = @name
               

                    "
                                   , TableMapping.TBL_PAGE

                                   );


                List <SqlParameter> parameters = new List <SqlParameter>();
                parameters.Add(CreateParameter("@name", SqlDbType.VarChar, page.ToString(), 20));

                Page item = new Page();
                DBConnect();
                SqlDataReader reader = ReadQuery(query.ToString(), parameters);

                while (reader.Read())
                {
                    int i = 0;
                    item.PageId      = ReadInt(ref reader, ref i);
                    item.Name        = ReadString(ref reader, ref i);
                    item.MenuEN      = ReadString(ref reader, ref i);
                    item.MenuFR      = ReadString(ref reader, ref i);
                    item.MenuSmallEN = ReadString(ref reader, ref i);
                    item.MenuSmallFR = ReadString(ref reader, ref i);
                    item.TitleEN     = ReadString(ref reader, ref i);
                    item.TitleFR     = ReadString(ref reader, ref i);
                    item.Type        = ReadString(ref reader, ref i);
                    item.LinkUrl     = ReadString(ref reader, ref i);


                    item.DisplayOrder = ReadInt(ref reader, ref i);
                }
                reader.Dispose();

                item.PageContent = FetchContent(page, true);

                DBDisconnect();


                return(item);
            }
            catch (Exception e)
            {
                log.ErrorFormat("Repository Error {0}", e.ToString());
                throw;
            }
        }