示例#1
0
        public async Task <ViewResult> Index()
        {
            var Post = GetAllpost();

            if (Post == null)
            {
                Response.StatusCode  = 404;
                ViewBag.ErrorMessage = "Sorry we couldn't reach the server at this point";
                return(View("NotFound"));
            }
            postDishOut Model = new postDishOut();

            Model.Manypost = Post;
            var typcount = _blogRepository.TypeCount();

            ViewBag.Allpost           = (IEnumerable <RePost>)Post;
            ViewBag.CatigoryTypeCount = typcount;
            // loading coins to layout
            var Crypto = await returnCoinToLayout();

            if (Crypto == null)
            {
                Response.StatusCode  = 404;
                ViewBag.ErrorMessage = "No network access (Please make your Internet is on)";
                return(View("NotFound"));
            }

            ViewBag.Crypto = Crypto;
            return(View(Model));
        }
示例#2
0
        public async Task <IActionResult> GetPostByHeadline(string HeadLine)
        {
            var TrimedHeadline       = HeadLine.Trim();
            IEnumerable <Post> posts = _blogRepository.GetPostByHeadline(TrimedHeadline);

            if (posts == null)
            {
                Response.StatusCode  = 404;
                ViewBag.ErrorMessage = "Sorry no news that matched searched terms";
                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.PosterName       = post.WhoPosted;
                postToUse.PostersPhotopath = post.PosterPhotopath;
                postToUse.PostId           = post.PostId;
                postToUse.postWriteUp      = post.postWriteUp;
                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));
        }
示例#3
0
        public async Task <IActionResult> Details(int Id)
        {
            var post = _blogRepository.GetPost(Id);

            if (post == null)
            {
                Response.StatusCode  = 404;
                ViewBag.ErrorMessage = "Sorry the news you looking for doesn't exist";
                return(View("NotFound"));
            }
            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.PosterName       = post.WhoPosted;
            postToUse.PostersPhotopath = post.PosterPhotopath;
            postToUse.postWriteUp      = post.postWriteUp;
            var         OurPost = _blogRepository.addLike(postToUse);
            var         Post    = _blogRepository.AddComent(OurPost);
            postDishOut Model   = new postDishOut();

            Model.post = 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(Model));
        }