public static List <ShareImage> DTConvertShareImage(DataTable dt) { List <ShareImage> modelList = new List <ShareImage>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { for (int i = 0; i < rowsCount; i++) { #region MyRegion DataRow row = dt.Rows[i]; int pkid = row.Field <int>("PKID"); string userId = row.Field <Guid>("userId").ToString(); string content = row.Field <string>("content"); bool isActive = row.Field <bool>("isActive"); bool isDelete = row.Field <bool>("isDelete"); DateTime createTime = row.Field <DateTime>("createTime"); DateTime updateTime = row.Field <DateTime>("lastUpdateTime"); int likeCount = row.Field <int>("likesCount"); int commentCount = row.Field <int>("commentCount"); int shareCount = row.Field <int>("shareCount"); List <ImagesDetail> imageDetails = DTConvertImagesDetail(ShareImageDAL.SelectShareImages(ProcessConnection.OpenMarketing, pkid)); modelList.Add(new ShareImage() { PKID = pkid, userId = userId, content = content, isActive = isActive, isDelete = isDelete, createTime = createTime, lastUpdateTime = updateTime, likesCount = likeCount, commentCount = commentCount, shareCount = shareCount, images = imageDetails, User = SelectUserInfo(userId) }); #endregion } } return(modelList); }
public static ShareImage SelectShareDetailByPKID(int PKID) { var row = ShareImageDAL.SelectShareDetailByPKID(ProcessConnection.OpenMarketing, PKID); if (row == null) { return(new ShareImage()); } int pkid = row.Field <int>("PKID"); List <ImagesDetail> imageDetails = DTConvertImagesDetail(ShareImageDAL.SelectShareImages(ProcessConnection.OpenMarketing, pkid)); string userId = row.Field <Guid>("userId").ToString(); string content = row.Field <string>("content"); bool isActive = row.Field <bool>("isActive"); bool isDelete = row.Field <bool>("isDelete"); DateTime createTime = row.Field <DateTime>("createTime"); DateTime updateTime = row.Field <DateTime>("lastUpdateTime"); int likeCount = row.Field <int>("likesCount"); int commentCount = row.Field <int>("commentCount"); int shareCount = row.Field <int>("shareCount"); return(new ShareImage { PKID = pkid, userId = userId, content = content, isActive = isActive, isDelete = isDelete, createTime = createTime, lastUpdateTime = updateTime, likesCount = likeCount, commentCount = commentCount, shareCount = shareCount, images = imageDetails, User = SelectUserInfo(userId) }); }