コード例 #1
0
ファイル: NewService.cs プロジェクト: xuannam120392/webtest
        public NewModel GetNewById(string id)
        {
            try
            {
                var newStore = new NewStore();
                var model    = new NewModel();
                var dt       = newStore.GetNewById(id);
                if (dt.Rows.Count == 0)
                {
                    return(null);
                }
                model.TITLE       = dt.Rows[0]["NEWS_TITLE"].ToString();
                model.CONTENT     = dt.Rows[0]["NEWS_CONTENT"].ToString();
                model.IMGPATH     = dt.Rows[0]["NEWS_IMGPATH"].ToString();
                model.STATUS      = dt.Rows[0]["NEWS_STATUS"].ToString().Trim() == "1";
                model.ORDER       = int.Parse(dt.Rows[0]["NEWS_ORDER"].ToString());
                model.CATEGORY_ID = int.Parse(dt.Rows[0]["CATEGORY_ID"].ToString());
                return(model);
            }

            catch (Exception)
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: NewService.cs プロジェクト: xuannam120392/webtest
 public IList <SelectListItem> GetCategoryByNew(string id)
 {
     try
     {
         var datas    = new List <SelectListItem>();
         var newStore = new NewStore();
         var dt       = newStore.GetNewById(id);
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             var item = new SelectListItem()
             {
                 Text  = dt.Rows[i]["CATEGORY_TITLE"].ToString(),
                 Value = dt.Rows[i]["CATEGORY_ID"].ToString()
             };
             datas.Add(item);
         }
         return(datas);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }