Exemplo n.º 1
0
        public IList<Core.Business.NewsPhoto> GetAllNewsPhoto()
        {
            IList<Core.Business.NewsPhoto> newsPhotolist = new List<Core.Business.NewsPhoto>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectNewsPhotosAll");

            if(reader != null)
            {
                while(reader.Read())
                {
                    Core.Business.NewsPhoto newsPhoto = new Core.Business.NewsPhoto();

                    if (!reader.IsDBNull(0)) newsPhoto.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) newsPhoto.Title = reader.GetString(1);
                    if (!reader.IsDBNull(2)) newsPhoto.PhotoSrc = reader.GetString(2);
                    if (!reader.IsDBNull(3)) newsPhoto.Author = reader.GetString(3);
                    if (!reader.IsDBNull(4)) newsPhoto.AddDate = reader.GetDateTime(4);
                    if (!reader.IsDBNull(5)) newsPhoto.ContentUrl = reader.GetString(5);
                    if (!reader.IsDBNull(6)) newsPhoto.Status = reader.GetInt32(6);
                    if (!reader.IsDBNull(7)) newsPhoto.ContentID = reader.GetGuid(7);
                    newsPhoto.MarkOld();
                    newsPhotolist.Add(newsPhoto);
                }
                reader.Close();
            }
            return newsPhotolist;
        }
Exemplo n.º 2
0
        public Core.Business.NewsPhoto Select(Guid id)
        {
            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@Id", SqlDbType.UniqueIdentifier, id);
            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectNewsPhoto");

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.NewsPhoto newsPhoto = new Core.Business.NewsPhoto();

                if (!reader.IsDBNull(0)) newsPhoto.Id = reader.GetGuid(0);
                if (!reader.IsDBNull(1)) newsPhoto.Title = reader.GetString(1);
                if (!reader.IsDBNull(2)) newsPhoto.PhotoSrc = reader.GetString(2);
                if (!reader.IsDBNull(3)) newsPhoto.Author = reader.GetString(3);
                if (!reader.IsDBNull(4)) newsPhoto.AddDate = reader.GetDateTime(4);
                if (!reader.IsDBNull(5)) newsPhoto.ContentUrl = reader.GetString(5);
                if (!reader.IsDBNull(6)) newsPhoto.Status = reader.GetInt32(6);
                if (!reader.IsDBNull(7)) newsPhoto.ContentID = reader.GetGuid(7);

                reader.Close();
                return newsPhoto;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }
Exemplo n.º 3
0
        public IEnumerable<NewsPhoto> Search(NewsPhotoJson json)
        {
            try
            {
                if (json == null)
                    throw new ArgumentNullException(" json is null ");

                IList<Core.Business.NewsPhoto> newsPhotolist = new List<Core.Business.NewsPhoto>();

                SqlServerUtility sql = new SqlServerUtility();

                sql.AddParameter("@module", SqlDbType.UniqueIdentifier, json.Module.Value);

                SqlDataReader reader = sql.ExecuteSqlReader(Sql_Search);

                if (reader != null)
                {
                    while (reader.Read())
                    {
                        Core.Business.NewsPhoto newsPhoto = new Core.Business.NewsPhoto();

                        if (!reader.IsDBNull(0)) newsPhoto.Id = reader.GetGuid(0);
                        if (!reader.IsDBNull(1)) newsPhoto.Title = reader.GetString(1);
                        if (!reader.IsDBNull(2)) newsPhoto.PhotoSrc = reader.GetString(2);
                        if (!reader.IsDBNull(3)) newsPhoto.Author = reader.GetString(3);
                        if (!reader.IsDBNull(4)) newsPhoto.AddDate = reader.GetDateTime(4);
                        if (!reader.IsDBNull(5)) newsPhoto.ContentUrl = reader.GetString(5);
                        if (!reader.IsDBNull(6)) newsPhoto.Status = reader.GetInt32(6);
                        if (!reader.IsDBNull(7)) newsPhoto.ContentID = reader.GetGuid(7);
                        newsPhoto.MarkOld();
                        newsPhotolist.Add(newsPhoto);
                    }
                    reader.Close();
                }
                return newsPhotolist;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public IList<NewsPhoto> SelectNewsPhotosDynamic(string sqlwhere)
        {
            IList<Core.Business.NewsPhoto> newsPhotolist = new List<Core.Business.NewsPhoto>();
            SqlServerUtility sql = new SqlServerUtility();
            StringBuilder sbOrderExpression = new StringBuilder();

            sbOrderExpression.Append("[AddDate] desc");
            sql.AddParameter("@WhereCondition", SqlDbType.NVarChar, sqlwhere);

            sql.AddParameter("@OrderByExpression", SqlDbType.NVarChar, sbOrderExpression.ToString());
            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectNewsPhotosDynamic");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.NewsPhoto newsPhoto = new Core.Business.NewsPhoto();

                    if (!reader.IsDBNull(0)) newsPhoto.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) newsPhoto.Title = reader.GetString(1);
                    if (!reader.IsDBNull(2)) newsPhoto.PhotoSrc = reader.GetString(2);
                    if (!reader.IsDBNull(3)) newsPhoto.Author = reader.GetString(3);
                    if (!reader.IsDBNull(4)) newsPhoto.AddDate = reader.GetDateTime(4);
                    if (!reader.IsDBNull(5)) newsPhoto.ContentUrl = reader.GetString(5);
                    if (!reader.IsDBNull(6)) newsPhoto.Status = reader.GetInt32(6);
                    if (!reader.IsDBNull(7)) newsPhoto.ContentID = reader.GetGuid(7);
                    newsPhoto.MarkOld();
                    newsPhotolist.Add(newsPhoto);
                }
                reader.Close();
            }
            return newsPhotolist;
        }
Exemplo n.º 5
0
        public IEnumerable<NewsPhoto> Search(NewsPhotoJson json, PagingInfo pageinfo)
        {
            if (json == null || pageinfo == null)
                throw new ArgumentNullException("json and pageinfo is null ");

            IList<Core.Business.NewsPhoto> newsPhotolist = new List<Core.Business.NewsPhoto>();

            SqlServerUtility sql = new SqlServerUtility();

            if (json.Module != null && json.Module.HasValue && json.Module.Value != Guid.Empty)
            {
                sql.AddParameter("@module", SqlDbType.UniqueIdentifier, json.Module);
            }

            sql.AddParameter("@pagesize", SqlDbType.Int, pageinfo.PageSize);

            sql.AddParameter("@pageindex", SqlDbType.Int, pageinfo.CurrentPage);

            SqlDataReader reader = sql.ExecuteSPReader("usp_SearchNewsPhoto");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.NewsPhoto newsPhoto = new Core.Business.NewsPhoto();

                    if (!reader.IsDBNull(0)) newsPhoto.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) newsPhoto.Title = reader.GetString(1);
                    if (!reader.IsDBNull(2)) newsPhoto.PhotoSrc = reader.GetString(2);
                    if (!reader.IsDBNull(3)) newsPhoto.Author = reader.GetString(3);
                    if (!reader.IsDBNull(4)) newsPhoto.AddDate = reader.GetDateTime(4);
                    if (!reader.IsDBNull(5)) newsPhoto.ContentUrl = reader.GetString(5);
                    if (!reader.IsDBNull(6)) newsPhoto.Status = reader.GetInt32(6);
                    if (!reader.IsDBNull(7)) newsPhoto.ContentID = reader.GetGuid(7);
                    newsPhoto.MarkOld();
                    newsPhotolist.Add(newsPhoto);
                }
                reader.Close();
            }
            return newsPhotolist;
        }