Example #1
0
        public async Task <IActionResult> GetPostByDiscription(int description)
        {
            var posts = _blogRepository.GetByDiscription((Category)description);

            if (posts == null)
            {
                Response.StatusCode  = 404;
                ViewBag.ErrorMessage = "Sorry there's no news yet on the searched category";
                return(View("NotFound"));
            }
            List <RePost> rePosts = new List <RePost>();

            foreach (var post in posts)
            {
                var postToUse = new RePost();
                postToUse.Date             = post.Date;
                postToUse.Discription      = post.Discription;
                postToUse.Headline         = post.Headline;
                postToUse.Photopath        = post.Photopath;
                postToUse.PostId           = post.PostId;
                postToUse.postWriteUp      = post.postWriteUp;
                postToUse.PosterName       = post.WhoPosted;
                postToUse.PostersPhotopath = post.PosterPhotopath;
                rePosts.Add(postToUse);
            }
            var         OurPost = _blogRepository.addLikes(rePosts);
            var         Post    = _blogRepository.AddComents(OurPost);
            postDishOut Model   = new postDishOut();

            Model.Manypost = Post;
            var all = GetAllpost();

            ViewBag.Allpost = (IEnumerable <RePost>)all;
            var typcount = _blogRepository.TypeCount();

            ViewBag.CatigoryTypeCount = (PostTypeCount)typcount;
            //var Crypto = await returnCoinToLayout();
            //ViewBag.Crypto = Crypto;
            return(View("Index", Model));
        }
Example #2
0
        public IEnumerable <RePost> GetAllpost()
        {
            List <RePost> rePosts    = new List <RePost>();
            var           NewsUpdate = _blogRepository.GetALLpost();

            foreach (var post in NewsUpdate)
            {
                var postToUse = new RePost();
                postToUse.Date        = post.Date;
                postToUse.Discription = post.Discription;
                postToUse.Headline    = post.Headline;
                postToUse.Photopath   = post.Photopath;
                postToUse.PostId      = post.PostId;
                postToUse.postWriteUp = post.postWriteUp;
                rePosts.Add(postToUse);
            }
            var OurPost = _blogRepository.addLikes(rePosts);
            var Post    = _blogRepository.AddComents(OurPost);

            return(Post);
        }