예제 #1
0
        public List<News_details_entity> Load_listnews(int _Catid)
        {
            try
            {
                List<News_details_entity> l = new List<News_details_entity>();
                var list = (from a in db.ESHOP_NEWS_CATs
                            join b in db.ESHOP_NEWs on a.NEWS_ID equals b.NEWS_ID
                            join c in db.ESHOP_CATEGORies on a.CAT_ID equals c.CAT_ID
                            where (c.CAT_ID == _Catid || c.CAT_PARENT_PATH.Contains(_Catid.ToString()))
                            select new { b.NEWS_ID, b.NEWS_TITLE, b.NEWS_IMAGE3, b.NEWS_DESC, b.NEWS_SEO_URL, b.NEWS_URL, b.NEWS_ORDER, b.NEWS_ORDER_PERIOD, b.NEWS_PUBLISHDATE }).Distinct().OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.NEWS_ORDER).ToList();
                foreach (var i in list)
                {
                    News_details_entity pro = new News_details_entity();
                    pro.NEWS_ID = i.NEWS_ID;
                    pro.NEWS_TITLE = i.NEWS_TITLE;
                    pro.NEWS_IMAGE3 = i.NEWS_IMAGE3;
                    pro.NEWS_DESC = i.NEWS_DESC;
                    pro.NEWS_SEO_URL = i.NEWS_SEO_URL;
                    pro.NEWS_URL = i.NEWS_URL;
                    pro.NEWS_ORDER = Utils.CIntDef(i.NEWS_ORDER);
                    pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD);
                    pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now);
                    
                    l.Add(pro);
                }
                return l;

            }
            catch (Exception)
            {

                throw;
            }
        }
예제 #2
0
        public List<News_details_entity> Load_listNewsHome(int limit)
        {
            try
            {
                List<News_details_entity> l = new List<News_details_entity>();
                var list = (from a in db.ESHOP_NEWS_CATs
                            join b in db.ESHOP_NEWs on a.NEWS_ID equals b.NEWS_ID
                            join c in db.ESHOP_CATEGORies on a.CAT_ID equals c.CAT_ID
                            where c.CAT_TYPE == 0
                            select new { b.NEWS_ID, b.NEWS_TITLE, b.NEWS_IMAGE3, b.NEWS_DESC, b.NEWS_SEO_URL, b.NEWS_URL, b.NEWS_ORDER, b.NEWS_ORDER_PERIOD, b.NEWS_PUBLISHDATE, c.CAT_SEO_URL, b.NEWS_CODE }).OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.NEWS_ORDER).ToList();
                foreach (var i in list)
                {
                    News_details_entity pro = new News_details_entity();
                    pro.NEWS_ID = i.NEWS_ID;
                    pro.NEWS_CODE = i.NEWS_CODE;
                    pro.NEWS_TITLE = i.NEWS_TITLE;
                    pro.NEWS_IMAGE3 = i.NEWS_IMAGE3;
                    pro.NEWS_DESC = i.NEWS_DESC;
                    pro.NEWS_SEO_URL = i.NEWS_SEO_URL;
                    pro.NEWS_URL = i.NEWS_URL;
                    pro.NEWS_ORDER = Utils.CIntDef(i.NEWS_ORDER);
                    pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD);
                    pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now);
                    pro.CAT_SEO_URL = i.CAT_SEO_URL;
                    l.Add(pro);
                }

                return l;

            }
            catch (Exception)
            {

                throw;
            }
        }
예제 #3
0
        // Load other news
        public List<News_details_entity> Load_othernews(int _newid)
        {
            try
            {
                List<News_details_entity> l = new List<News_details_entity>();
                if (_newid != 0)
                {
                    var s = (from c in db.ESHOP_NEWS_CATs
                             join a in db.ESHOP_NEWs on c.NEWS_ID equals a.NEWS_ID
                             join b in db.ESHOP_CATEGORies on c.CAT_ID equals b.CAT_ID
                             where a.NEWS_ID == _newid
                             select new { b.CAT_ID }).ToList();
                    if (s.Count > 0)
                    {
                        var _tinTucKhac = (from c in db.ESHOP_NEWS_CATs
                                           join a in db.ESHOP_NEWs on c.NEWS_ID equals a.NEWS_ID
                                           join b in db.ESHOP_CATEGORies on c.CAT_ID equals b.CAT_ID
                                           where a.NEWS_ID != _newid && b.CAT_ID == s[0].CAT_ID
                                           select new {a.NEWS_COUNT, a.NEWS_FIELD2, a.NEWS_FIELD3, a.NEWS_FIELD1, a.NEWS_FIELD4, a.NEWS_PRICE2, a.NEWS_ID, a.NEWS_TITLE, a.NEWS_IMAGE3, a.NEWS_PRICE1, a.NEWS_DESC, a.NEWS_SEO_URL, a.NEWS_URL, a.NEWS_ORDER, a.NEWS_ORDER_PERIOD, a.NEWS_PUBLISHDATE }).Distinct().OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.NEWS_ORDER).Take(10).Distinct();
                        if (_tinTucKhac.ToList().Count > 0)
                        {
                            foreach (var i in _tinTucKhac)
                            {
                                News_details_entity pro = new News_details_entity();
                                pro.NEWS_COUNT = Utils.CIntDef(i.NEWS_COUNT);
                                pro.NEWS_ID = i.NEWS_ID;
                                pro.NEWS_TITLE = i.NEWS_TITLE;
                                pro.NEWS_IMAGE3 = i.NEWS_IMAGE3;
                                pro.NEWS_DESC = i.NEWS_DESC;
                                pro.NEWS_SEO_URL = i.NEWS_SEO_URL;
                                pro.NEWS_URL = i.NEWS_URL;
                                pro.NEWS_ORDER = Utils.CIntDef(i.NEWS_ORDER);
                                pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD);
                                pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now);
                                pro.NEWS_PRICE1 = Utils.CDecDef(i.NEWS_PRICE1);
                                pro.NEWS_PRICE2 = Utils.CDecDef(i.NEWS_PRICE2);
                                pro.NEWS_FIELD1 = Utils.CStrDef(i.NEWS_FIELD1);
                                pro.NEWS_FIELD2 = Utils.CStrDef(i.NEWS_FIELD2);
                                pro.NEWS_FIELD3 = Utils.CStrDef(i.NEWS_FIELD3);
                                pro.NEWS_FIELD4 = Utils.CStrDef(i.NEWS_FIELD4);
                                l.Add(pro);
                            }
                        }
                    }

                }
                return l;
               
            }
            catch (Exception ex)
            {

                clsVproErrorHandler.HandlerError(ex);
                return null;
            }
        }
        // Load other news
        public List<News_details_entity> Load_othernews(string _sNews_Seo_Url)
        {
            try
            {
                List<News_details_entity> l = new List<News_details_entity>();
                if (_sNews_Seo_Url != "")
                {
                    var s = (from c in db.ESHOP_NEWS_CATs
                             join a in db.ESHOP_NEWs on c.NEWS_ID equals a.NEWS_ID
                             join b in db.ESHOP_CATEGORies on c.CAT_ID equals b.CAT_ID
                             where a.NEWS_SEO_URL == _sNews_Seo_Url
                             select new { b.CAT_ID}).ToList();
                    if (s.Count > 0)
                    {
                        var _tinTucKhac = (from c in db.ESHOP_NEWS_CATs
                                           join a in db.ESHOP_NEWs on c.NEWS_ID equals a.NEWS_ID
                                           join b in db.ESHOP_CATEGORies on c.CAT_ID equals b.CAT_ID
                                           where a.NEWS_SEO_URL != _sNews_Seo_Url && b.CAT_ID == s[0].CAT_ID
                                           select new { a.NEWS_ID, a.NEWS_TITLE, a.NEWS_IMAGE3, a.NEWS_PRICE1, a.NEWS_DESC, a.NEWS_SEO_URL, a.NEWS_URL, a.NEWS_ORDER, a.NEWS_ORDER_PERIOD, a.NEWS_PUBLISHDATE, c.ESHOP_CATEGORy.CAT_SEO_URL }).OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.NEWS_ORDER).Take(9).Distinct();
                        if (_tinTucKhac.ToList().Count > 0)
                        {
                            foreach (var i in _tinTucKhac)
                            {
                                News_details_entity pro = new News_details_entity();
                                pro.NEWS_ID = i.NEWS_ID;
                                pro.NEWS_TITLE = i.NEWS_TITLE;
                                pro.NEWS_IMAGE3 = i.NEWS_IMAGE3;
                                pro.NEWS_DESC = i.NEWS_DESC;
                                pro.NEWS_SEO_URL = i.NEWS_SEO_URL;
                                pro.NEWS_URL = i.NEWS_URL;
                                pro.NEWS_ORDER = Utils.CIntDef(i.NEWS_ORDER);
                                pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD);
                                pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now);
                                pro.CAT_SEO_URL = i.CAT_SEO_URL;
                                l.Add(pro);
                            }
                        }
                    }
                }
                return l;
               
            }
            catch (Exception ex)
            {

                clsVproErrorHandler.HandlerError(ex);
                return null;
            }
        }