コード例 #1
0
ファイル: PostsModels.cs プロジェクト: robiboi/blurt.ph
        /// <summary>
        /// Get Posts with paging.
        /// </summary>
        /// <param name="PageSize">Number of results per page.</param>
        /// <param name="Index">Last Index of result</param>
        /// <returns></returns>
        public List<PostsModels> GetPosts(int PageSize, int Index)
        {
            MensaheRepository mr = new MensaheRepository();
            TagIyaRepository tir = new TagIyaRepository();
            try
            {
                var msgs = mr.GetAllMessage().OrderByDescending(m=>m.DatePosted).ToList();

                if (msgs.Count > PageSize)
                    msgs = msgs.GetRange(Index, PageSize);

                List<PostsModels> posts = new List<PostsModels>();
                
                foreach (Mensahe msg in msgs)
                {
                    var tagIya = tir.GetUserbyMsgId(msg.MessageId);
                    // we don't want to display the message for those non-existing users
                    if (tagIya != null)
                    {
                        PostsModels post = this.GetPostsModel(tagIya, msg);
                        posts.Add(post);
                    }
                }
                return posts;
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
ファイル: PostsModels.cs プロジェクト: robiboi/blurt.ph
        /// <summary>
        /// Get Post by Message id
        /// </summary>
        /// <param name="MessageId">Message Id</param>
        /// <returns></returns>
        public static PostsModels GetPostByMessageId(int MessageId)
        {
            MensaheRepository mr = new MensaheRepository();
            TagIyaRepository tir = new TagIyaRepository();

            try
            {
                var msg = mr.GetMessage(MessageId);
                var tagIya = tir.GetUserbyMsgId(MessageId);

                PostsModels post = new PostsModels();
                post = post.GetPostsModel(tagIya, msg);

                return post;
            }
            catch
            {
                throw;
            }
        }
コード例 #3
0
ファイル: PostsModels.cs プロジェクト: robiboi/blurt.ph
        public void CreatePost()
        {
            MensaheRepository mr = new MensaheRepository();
            TagIyaRepository tir = new TagIyaRepository();
            try
            {
                Mensahe msg = new Mensahe();
                msg.Message = this.Message;
                msg.DatePosted = DateTime.Now;
                msg.DateEdited = DateTime.Now;

                mr.InsertMessage(msg, tir.GetTagIya(this.PostUserId));
            }
            catch
            {
                throw;
            }
        }
コード例 #4
0
ファイル: PostsModels.cs プロジェクト: robiboi/blurt.ph
        /// <summary>
        /// Get posts by User
        /// </summary>
        /// <param name="UserId">User Id</param>
        /// <returns></returns>
        public static List<PostsModels> GetPostsByUser(int UserId)
        {
            MensaheRepository mr = new MensaheRepository();
            TagIyaRepository tir = new TagIyaRepository();

            try
            {
                var msgs = mr.GetUserMessages(UserId);
                var tagIya = tir.GetTagIya(UserId);

                List<PostsModels> posts = new List<PostsModels>();
                foreach (Mensahe msg in msgs)
                {
                    PostsModels post = new PostsModels();
                    post = post.GetPostsModel(tagIya, msg);
                    posts.Add(post);
                }
                return posts;
            }
            catch
            {
                throw;
            }
        }