public ActionResult <List <PostDto> > GetPosts(string?userName, [FromHeader] int accountID) { List <Post> posts; if (userName != null) { UserAccountDto user = userMockRepository.GetAccountByUserName(userName); int userID = user.UserAccountId; posts = postRepository.GetPostByUser(userID, accountID); if (posts == null) { return(StatusCode(StatusCodes.Status400BadRequest, "You can't see the posts because the user is blocked!")); } } else { posts = postRepository.GetPosts(); if (posts == null || posts.Count == 0) { return(NoContent()); } } fakeLoggerRepository.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "Get all posts", null); return(Ok(mapper.Map <List <PostDto> >(posts))); }
public ActionResult <List <PictureDto> > GetPictures(Guid?postID) { var pictures = pictureRepository.GetPictures(postID); if (pictures == null || pictures.Count == 0) { return(NoContent()); } fakeLoggerRepository.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "Get all pictures", null); return(Ok(mapper.Map <List <PictureDto> >(pictures))); }
public ActionResult <List <ContentDto> > GetContents(string title) { var contents = contentRepository.GetContents(title); if (contents == null || contents.Count == 0) { return(NoContent()); } fakeLoggerRepository.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "Get all contents", null); return(Ok(mapper.Map <List <ContentDto> >(contents))); }