public ActionResult <IEnumerable <Post> > GetAll() { try { return(Ok(_ps.Get())); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <List <Post> > Get(string userId, string guestId) { List <Post> postsToWall = new List <Post>(); User user = _userService.Get(userId); User guestUser = _userService.Get(guestId); foreach (var id in user.BlockedUserId) { if (guestId == id) { return(NoContent()); } } foreach (var postId in user.PostId) { postsToWall.Add(_postsService.Get(postId)); } List <string> circleIdList = new List <string>(); foreach (var circleId in user.CircleId) { foreach (var circleIdOther in guestUser.CircleId) { if (circleId == circleIdOther) { circleIdList.Add(circleId); } } } foreach (var circleId in circleIdList) { Circle circle = _circleService.Get(circleId); foreach (var postId in circle.PostId) { var post = _postsService.Get(postId); if (post.UserId == userId) { postsToWall.Add(post); } } } return(postsToWall); }
public ActionResult Index() { var model = new HomePageModel(); model.Posts = postsService.Get()?.Where(post => post.IsPublished).ToList(); return(View(model)); }
public ActionResult <IEnumerable <Post> > Get() { try { return(Ok(_ps.Get())); } catch (Exception error) { return(BadRequest(error.Message)); } }
public ActionResult <List <Post> > Get(string id) { List <Post> postsInFeed = new List <Post>(); var user = _userService.Get(id); if (user == null) { return(NotFound()); } foreach (var postId in user.PostId) { postsInFeed.Add(_postsService.Get(postId)); } if (user.CircleId != null) { foreach (var circleId in user.CircleId) { var Circle = _circleService.Get(circleId); foreach (var postId in Circle.PostId) { postsInFeed.Add(_postsService.Get(postId)); } } } if (user.FollowUserId != null) { foreach (var followUserId in user.FollowUserId) { var User = _userService.Get(followUserId); foreach (var postId in User.PostId) { postsInFeed.Add(_postsService.Get(postId)); } } } return(postsInFeed); }
public async void Get_null_record() { var mock = new ServiceMockFacade <IPostsRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Posts>(null)); var service = new PostsService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.PostsModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLPostsMapperMock, mock.DALMapperMockFactory.DALPostsMapperMock); ApiPostsResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public ActionResult <List <Post> > Get() { return(_postsService.Get()); }