Exemplo n.º 1
0
        /// <summary>
        /// Get by ID
        /// </summary>
        /// <param name="_id"></param>
        /// <returns></returns>
        public CoreData.Article GetByID(long _id)
        {
            try
               {
               DictionaryDefine df = new DictionaryDefine();

               var data = entity.GetById(_id, Table.Article.ToString());

               foreach (var item in df.DicArticleCategory)
               {
                   if (data.CateID == item.Key)
                    {
                        data.CateID = item.Key;
                        data.CategoryNameExt = item.Value;
                        data.View = data.View + 1;
                        Save(data);
                    }
               }
               return data;
               }
               catch { return null; }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get List
        /// </summary>
        /// <returns></returns>
        public IList<CoreData.Article> GetList()
        {
            try
               {
               DictionaryDefine df = new DictionaryDefine();

               var list = entity.GetByCusTomSQL(SQLCommand.GetArticleList).ToList();
               foreach (var item in df.DicArticleCategory)
               {
                   for (int i = 0; i < list.Count; i++)
                   {
                       if (list[i].CateID == item.Key)
                       {
                           list[i].CateID = item.Key;
                           list[i].CategoryNameExt = item.Value;
                       }
                   }
               }
               //return entity.GetByCusTomSQL(SQLCommand.GetArticleList).ToList();
               return list;
               }
               catch { return null; }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Get Article by Category ID
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public IList<Article> GetListByRelationsID(long catid, string username)
 {
     try
     {
         string tempstring = "";
         string getuserid = "";
         if (username == "" && catid == 0)
         {
             tempstring = "";
         }
         else
         {
             if (username != "" && catid == 0)
             {
                 tempstring = " and u.UserName LIKE '" + username + "'";
                 getuserid = ", u.Name AS UserName";
             }
             if (catid != 0) {
                 if (username == "")
                 {
                     tempstring = " and a.CateID = '" + catid + "'";
                 }
                 else
                 {
                     tempstring = " and u.UserName LIKE '" + username + "'" + " and CateID = '" + catid + "'";
                     getuserid = ", u.Name AS UserName";
                 }
             }
         }
         var list = entity.GetByCusTomSQL(String.Format(SQLCommand.GetListByRelationsID,getuserid, tempstring)).ToList();
         DictionaryDefine df = new DictionaryDefine();
         if (catid != 0)
         {
             foreach (var item in df.DicArticleCategory)
             {
                 for (int i = 0; i < list.Count; i++)
                 {
                     if (list[i].CateID == item.Key)
                     {
                         list[i].CateID = item.Key;
                         list[i].CategoryNameExt = item.Value;
                     }
                 }
             }
         }
         return list;
     }
     catch { return null; }
 }
Exemplo n.º 4
0
 public List<SelectListItem> GetListCategory(int id)
 {
     var lst = new List<SelectListItem>();
     DictionaryDefine listcate = new DictionaryDefine();
     foreach (var item in listcate.DicArticleCategory) {
         var sitem = new SelectListItem();
         sitem.Value = item.Key.ToString();
         sitem.Text = item.Value;
         lst.Add(sitem);
     }
     return lst;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Get List with search string
        /// </summary>
        /// <returns></returns>
        public IList<CoreData.Article> GetList(string _searchstring)
        {
            //search theo tieu chi nao do
               try
               {
               DictionaryDefine df = new DictionaryDefine();

               var list = entity.GetBySearchString(_searchstring, Table.Article.ToString()).ToList();
               foreach (var item in df.DicArticleCategory)
               {
                   for (int i = 0; i < list.Count; i++)
                   {
                       if (list[i].CateID == item.Key)
                       {
                           list[i].CateID = item.Key;
                           list[i].CategoryNameExt = item.Value;
                       }
                   }
               }
               //return entity.GetBySearchString(_searchstring, Table.Article.ToString()).ToList();
               return list;
               }
               catch { return null; }
        }