Esempio n. 1
0
        /// <summary>
        /// Gets all the PhotoComment in the database
        /// </summary>
        public static List <AjaxComment> GetPhotoCommentsByGalleryID(int PhotoCollectionID)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("HG_GetPhotoCommentsByGalleryID");

            db.AddInParameter(dbCommand, "PhotoCollectionID", DbType.Int32, PhotoCollectionID);

            List <AjaxComment> commentArr = new List <AjaxComment>();

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                while (dr.Read())
                {
                    AjaxComment ajaxComment = new AjaxComment();

                    ajaxComment.WebMemberID    = (string)dr["WebMemberID"];
                    ajaxComment.WebPhotoID     = (string)dr["WebPhotoID"];
                    ajaxComment.NickName       = (string)dr["NickName"];
                    ajaxComment.PhotoUrl       = ParallelServer.Get((string)dr["PhotoUrl"]) + "user/" + (string)dr["PhotoUrl"];
                    ajaxComment.Text           = (string)dr["Text"];
                    ajaxComment.DateTimePosted = TimeDistance.TimeAgo((DateTime)dr["DTCreated"]);

                    commentArr.Add(ajaxComment);
                }


                dr.Close();
            }

            // Create the object array from the datareader
            return(commentArr);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="NSpotID"></param>
        /// <returns></returns>
        public static AjaxComment[] GetNSpotCommentByNSpotIDWithJoin(int NSpotID)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("HG_GetNSpotCommentByNSpotIDWithJoin");

            db.AddInParameter(dbCommand, "NSpotID", DbType.Int32, NSpotID);

            AjaxComment[] ajaxComments = new AjaxComment[0];

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                ajaxComments = PopulateAjaxComment(db.ExecuteReader(dbCommand));
            }

            return(ajaxComments);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        public static AjaxComment[] PopulateAjaxComment(IDataReader dr)
        {
            List <AjaxComment> commentArr = new List <AjaxComment>();
            AjaxComment        ajaxComment;

            ColumnFieldList list = new ColumnFieldList(dr);

            while (dr.Read())
            {
                ajaxComment = new AjaxComment();

                ajaxComment.WebMemberID    = (string)dr["WebMemberID"];
                ajaxComment.NickName       = (string)dr["NickName"];
                ajaxComment.PhotoUrl       = ParallelServer.Get((string)dr["PhotoUrl"]) + "user/" + (string)dr["PhotoUrl"];
                ajaxComment.Text           = (string)dr["Text"];
                ajaxComment.SentFromMobile = ((int)dr["SentFromMobile"]) == 1 ? true : false;
                ajaxComment.DateTimePosted = TimeDistance.TimeAgo((DateTime)dr["DTCreated"]);
                ajaxComment.DTCreated      = (DateTime)dr["DTCreated"];

                if (list.IsColumnPresent("WebCommentID"))
                {
                    ajaxComment.WebCommentID = (string)dr["WebCommentID"];
                }
                if (list.IsColumnPresent("Path"))
                {
                    ajaxComment.Path  = (string)dr["Path"];
                    ajaxComment.Depth = GetDepth(ajaxComment.Path);
                }
                if (list.IsColumnPresent("IsDeleted"))
                {
                    ajaxComment.IsDeleted = (bool)dr["IsDeleted"];
                }

                commentArr.Add(ajaxComment);
            }

            return(commentArr.ToArray());
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="MemberCommentID"></param>
        /// <returns></returns>
        public static AjaxComment GetAjaxNSpotCommentByNSpotCommentIDWithJoin(int NSpotCommentID)
        {
            var db        = DatabaseFactory.CreateDatabase();
            var dbCommand = db.GetStoredProcCommand("HG_GetAjaxNSpotCommentByNSpotCommentIDWithJoin");

            db.AddInParameter(dbCommand, "NSpotCommentID", DbType.Int32, NSpotCommentID);

            var ajaxComments = new AjaxComment[0];

            using (var dr = db.ExecuteReader(dbCommand))
            {
                ajaxComments = PopulateAjaxComment(db.ExecuteReader(dbCommand));
            }

            if (ajaxComments.Length > 0)
            {
                return(ajaxComments[0]);
            }
            else
            {
                throw new Exception(String.Format(Properties.Resources.Argument_InvalidNSpotCommentID, NSpotCommentID));
            }
        }