Ejemplo n.º 1
6
        public void AddPost(Post post)
        {
            // Parse Tags into separate hash tags
            if (post.Tags != null)
            {
                var hashtags = post.Tags.Replace("#", "").Split(',');

                foreach (var hashtag in hashtags)
                {
                    if (hashtag != "")
                    {
                        var p = new HashTag();

                        p.ActualHashTag = hashtag;
                        post.HashTags.Add(p);
                    }
                }
            }

            var create = new Create();
            var postID = create.AddPost(post);

            // Check if post add was successful and returned the new postID
            if (postID != null && post.HashTags.Count() != 0)
            {
                foreach (var tag in post.HashTags)
                {
                    create.AddTag((int) postID, tag);
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult EditPost(Post post)
        {
            var update = new FITlosophiOperations();

            update.EditPost(post);

            return View("ManagePosts");
        }
Ejemplo n.º 3
0
        public void PublishPost(int PostID)
        {
            var post = new Post();
            post.PostID = PostID;

            var update = new FITlosophiOperations();

            update.PublishPost(post);
        }
Ejemplo n.º 4
0
        public void AddPost()
        {
            Post newpost = new Post();

            newpost.CategoryID = 1;
            newpost.UserID = "b75da91b-e39a-42ce-b2f0-4834eda139e1";
            newpost.Title = "My Test Post for data layer";
            newpost.CoverImgURL = "http://localhost:54909/Content/img/golf.jpg";
            newpost.Body = "Test Body";

            var result = Createrepo.AddPost(newpost);

            var posts = Readrepo.GetAllPostSummaries();
            var post = posts.FirstOrDefault(p => p.PostID == result);

            Assert.AreEqual(post.PostID, result);
        }
Ejemplo n.º 5
0
        public void EditPost(Post post)
        {
            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var p = new DynamicParameters();

                try
                {
                    p.Add("PostID", post.PostID);
                    p.Add("CategoryID", post.CategoryID);
                    p.Add("UserID", post.UserID);
                    p.Add("Title", post.Title);
                    p.Add("CoverImgURL", post.CoverImgURL);
                    p.Add("Body", post.Body);
                    p.Add("HasSchedule", post.HasSchedule);
                    p.Add("StartDate", post.StartDate);
                    p.Add("EndDate", post.EndDate);

                    cn.Execute("EditPost", p, commandType: CommandType.StoredProcedure);

                }
                //catch (Exception e)
                //{
                //    // Write failure to database
                //    var ep = new DynamicParameters();

                //    ep.Add("ExceptionType", e.GetType());
                //    ep.Add("ExceptionMessage", e.Message);
                //    cn.Execute("AddError", ep, commandType: CommandType.StoredProcedure);
                //}
                finally
                {
                    cn.Close();
                }
            }
        }
Ejemplo n.º 6
0
        public void PublishPostWithSchedule(Post Post)
        {
            var update = new FITlosophiOperations();

            update.PublishPost(Post);
        }
Ejemplo n.º 7
0
        public void Post(Post post)
        {
            var create = new FITlosophiOperations();

            create.AddPost(post);
        }
Ejemplo n.º 8
0
        public void EditPost(Post Post)
        {
            var update = new FITlosophiOperations();

            update.EditPost(Post);
        }
Ejemplo n.º 9
0
        public void PublishPost()
        {
            Post post = new Post();

            post.PostID = 4;
            post.HasSchedule = false;
            post.StartDate = null;
            post.EndDate = null;

            Updaterepo.PublishPost(post);

            var newpost = Readrepo.GetAllPostSummaries();

            Assert.AreEqual(false, newpost.Where(m=> m.PostID == 4).FirstOrDefault(x => x.HasSchedule == false ).HasSchedule);
        }
Ejemplo n.º 10
0
        public void EditPost()
        {
            Post newPost = new Post();

            newPost.PostID = 15;
            newPost.CategoryID = 3;
            newPost.UserID = "b75da91b-e39a-42ce-b2f0-4834eda139e1";
            newPost.Title = "Test post 44";
            newPost.CoverImgURL = "http://localhost:54909/Content/img/eating.jpg";
            newPost.Body = "Hi";
            newPost.DateCreated = DateTime.Parse("12/07/2015");
            newPost.HasSchedule = false;
            newPost.IsPublished = false;
            newPost.IsActive = false;

               Updaterepo.EditPost(newPost);

            var newbody = Readrepo.GetPostByID(15);

            Assert.AreEqual("Hi", newbody.Body);
        }
Ejemplo n.º 11
0
        public ActionResult PostPost(Post post)
        {
            var create = new FITlosophiOperations();

            create.AddPost(post);

            if (User.IsInRole("Admin"))
            {
                return View("ManagePosts");
            }

            return RedirectToAction("Index", "Home");
        }
Ejemplo n.º 12
0
        public void EditPost(Post post)
        {
            // Overwrite post with edited data
            var update = new Update();

            update.EditPost(post);

            // Delete all hashtags associated with post from PostsXTags table
            var delete = new Delete();

            delete.DeleteAllTagsByPostID(post.PostID);

            // Split up tags string from UI into individual hashtags. Then remove all # symbols.
            // Afterwards, only tags that contain characters are added to the HashTags list.
            if (post.Tags != null)
            {
                var hashtags = post.Tags.Replace("#", "").Split(',');

                foreach (var hashtag in hashtags)
                {
                    if (hashtag != "")
                    {
                        var p = new HashTag();

                        p.ActualHashTag = hashtag;
                        post.HashTags.Add(p);
                    }
                }
            }

            // Iterate: Check if hashtag is in Tags table. If not, create a new record in that table
            // before creating a new record in PostsXTags. Else, just create new record in PostsXTags.
            if (post.HashTags.Count() != 0)
            {
                var create = new Create();

                foreach (var tag in post.HashTags)
                {
                    create.AddTag((int)post.PostID, tag);
                }
            }
        }
Ejemplo n.º 13
0
        public void PublishPost(Post post)
        {
            var update = new Update();

            update.PublishPost(post);
        }