Exemple #1
0
        /// <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;
            }
        }
Exemple #2
0
        public void UpdateUser()
        {
            TagIyaRepository tir = new TagIyaRepository();

            try
            {
                tir.UpdateUser(this.UserId, this.DisplayName, this.Gravatar, this.FullName, this.Location, this.BirthDate);
            }
            catch
            {
                throw;
            }
        }
Exemple #3
0
        public UsersModels CreateNewUser(string openId, string openIdFriendly, string email)
        {
            TagIyaRepository tir = new TagIyaRepository();

            try
            {
                TagIya newUser = tir.CreateNewUser(openId, openIdFriendly, email);
                return(GetUserModel(newUser));
            }
            catch
            {
                throw;
            }
        }
Exemple #4
0
        public void CreateOpenIdForUser(string openId, string openIdFriendly)
        {
            if (UserId < 0)
            {
                throw new ArgumentNullException("UserId", "User needed for OpenId.");
            }

            TagIyaRepository tir = new TagIyaRepository();

            try
            {
                tir.CreateOpenIdForUser(this.UserId, openId, openIdFriendly);
            }
            catch
            {
                throw;
            }
        }
Exemple #5
0
        public UsersModels GetUserByOpenId(string openId)
        {
            if (string.IsNullOrEmpty(openId))
            {
                throw new ArgumentNullException("OpenId");
            }

            TagIyaRepository tir    = new TagIyaRepository();
            TagIya           tagIya = tir.GetTagIyaByOpenId(openId);

            if (tagIya != null)
            {
                return(GetUserModel(tagIya));
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
        public UsersModels GetUser()
        {
            if (this.UserId < 0)
            {
                throw new ArgumentNullException("UserId", "Primary key missing");
            }

            TagIyaRepository tir = new TagIyaRepository();

            try
            {
                var tagIya = tir.GetTagIya(this.UserId);
                return(GetUserModel(tagIya));
            }
            catch
            {
                throw;
            }
        }
Exemple #7
0
        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;
            }
        }
Exemple #8
0
        /// <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;
            }
        }
Exemple #9
0
        /// <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;
            }
        }