Example #1
0
 public static GetPost GetPostDS(DataSet ds)
 {
     try
     {
         GetPost post = new GetPost();
         post.Id      = (int)ds.Tables[0].Rows[0]["Id"];
         post.Title   = ds.Tables[0].Rows[0]["Title"].ToString();
         post.Content = ds.Tables[0].Rows[0]["Content"].ToString();
         post.Photo   = ds.Tables[0].Rows[0]["Photo"].ToString();
         GetCategory category = new GetCategory();
         category.Id   = (int)ds.Tables[0].Rows[0]["Category"];
         category.Name = ds.Tables[0].Rows[0]["Name"].ToString();
         post.Category = category;
         post.OnDate   = (System.DateTime)ds.Tables[0].Rows[0]["OnDate"];
         GetUser user = new GetUser();
         user.Id        = (int)ds.Tables[0].Rows[0]["ByUser"];
         user.Firstname = ds.Tables[0].Rows[0]["Firstname"].ToString();
         user.Lastname  = ds.Tables[0].Rows[0]["Lastname"].ToString();
         post.ByUser    = user;
         return(post);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
Example #2
0
        public static List <GetPost> GetAllPostDS(DataSet ds)
        {
            List <GetPost> list = new List <GetPost>();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                GetPost post = new GetPost();
                post.Id       = (int)ds.Tables[0].Rows[i]["Id"];
                post.Title    = ds.Tables[0].Rows[i]["Title"].ToString();
                post.Content  = ds.Tables[0].Rows[i]["Content"].ToString();
                post.Photo    = ds.Tables[0].Rows[i]["Photo"].ToString();
                post.Category = (int)ds.Tables[0].Rows[i]["Category"];
                post.OnDate   = (System.DateTime)ds.Tables[0].Rows[i]["OnDate"];
                post.ByUser   = (int)ds.Tables[0].Rows[i]["ByUser"];
                list.Add(post);
            }
            return(list);
        }
Example #3
0
 public static GetPost GetPostDS(DataSet ds)
 {
     try
     {
         GetPost post = new GetPost();
         post.Id       = (int)ds.Tables[0].Rows[0]["Id"];
         post.Title    = ds.Tables[0].Rows[0]["Title"].ToString();
         post.Content  = ds.Tables[0].Rows[0]["Content"].ToString();
         post.Photo    = ds.Tables[0].Rows[0]["Photo"].ToString();
         post.Category = (int)ds.Tables[0].Rows[0]["Category"];
         post.OnDate   = (System.DateTime)ds.Tables[0].Rows[0]["OnDate"];
         post.ByUser   = (int)ds.Tables[0].Rows[0]["ByUser"];
         return(post);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #4
0
        public static List <GetPost> GetAllPostDS(DataSet ds)
        {
            List <GetPost> list = new List <GetPost>();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                GetPost post = new GetPost();
                post.Id      = (int)ds.Tables[0].Rows[i]["Id"];
                post.Title   = ds.Tables[0].Rows[i]["Title"].ToString();
                post.Content = ds.Tables[0].Rows[i]["Content"].ToString();
                post.Photo   = ds.Tables[0].Rows[i]["Photo"].ToString();
                GetCategory category = new GetCategory();
                category.Id   = (int)ds.Tables[0].Rows[0]["Category"];
                category.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                post.Category = category;
                post.OnDate   = (System.DateTime)ds.Tables[0].Rows[0]["OnDate"];
                GetUser user = new GetUser();
                user.Id        = (int)ds.Tables[0].Rows[0]["ByUser"];
                user.Firstname = ds.Tables[0].Rows[0]["Firstname"].ToString();
                user.Lastname  = ds.Tables[0].Rows[0]["Lastname"].ToString(); list.Add(post);
            }
            return(list);
        }