Exemple #1
0
        // GET api/posts/f12
        public IEnumerable <Post> Get(string topic)
        {
            var pm = new PostsManager();

            pm.Initialize();
            return(pm.GetPosts(topic));
        }
        public async void GetAllPosts()
        {
            DbContextOptions <PostsDbContext> options = new DbContextOptionsBuilder <PostsDbContext>().UseInMemoryDatabase("GetAllPosts").Options;

            using (PostsDbContext context = new PostsDbContext(options))
            {
                PostsManager postService = new PostsManager(context);
                Posts        post        = new Posts();
                post.Author   = "Cat";
                post.ImageURL = "test.img";
                post.Title    = "Seattle";
                await postService.SaveAsync(post);

                Posts postTwo = new Posts();
                post.Author   = "Cats";
                post.ImageURL = "test.img";
                post.Title    = "Seattle2";
                await postService.SaveAsync(postTwo);

                Posts postThree = new Posts();
                post.Author   = "Cat3";
                post.ImageURL = "test.img";
                post.Title    = "Seattle3";
                await postService.SaveAsync(postThree);

                var result = await postService.GetPosts();

                int count = result.Count;

                Assert.Equal(3, count);
            }
        }
        public HttpResponseMessage GetPostsByUser(string id, string lang)
        {
            List <PostDto> posts  = postsManager.GetPosts(id);
            List <Post>    result = posts.ConvertAll(post => new Post(post));

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        private SpaInitialDataViewModel LoadData()
        {
            string loggedUser = User.Identity.Name;

            List <string> friends = ssnSecurityService.GetUsers();

            friends.Remove(User.Identity.Name);

            List <PostDto> postsDto = postsManager.GetPosts(loggedUser);
            List <Post>    posts    = postsDto.ConvertAll(post => new Post(post));

            return(new SpaInitialDataViewModel(loggedUser, friends, posts));
        }
Exemple #5
0
        public ActionResult Index()
        {
            var news   = newsManager.GetNews();
            var posts  = postsManager.GetPosts();
            var videos = videosManager.GetVideos();
            var index  = new App.Models.HomeViewModels()
            {
                New1   = news,
                Posts1 = posts,
                Video1 = videos,
            };

            return(View(index));
        }
        public ActionResult Index()
        {
            HttpCookie FromRequest = Request.Cookies["MyPosts"];
            List <int> ids         = new List <int>();

            if (FromRequest != null)
            {
                string userids = FromRequest.Value.ToString();
                ids = userids.Split(',').Select(Int32.Parse).ToList();
                //List<int> numbers = new List<int>(Array.ConvertAll(userids.Split(','), int.Parse));
                //ids = numbers;
            }

            List <Post> posts = mng.GetPosts();

            posts.ForEach(x => x.IsUsers = ids.Contains(x.Id));

            return(View(posts));
        }
Exemple #7
0
        // GET api/posts/f12
        public IEnumerable <Post> Get(string topic)
        {
            var pm = new PostsManager(_projectList);

            return(pm.GetPosts(topic));
        }