public async Task <IActionResult> GetPosts() { try { var posts = await _postService.GetPosts(); List <PostViewModel> completePosts = new List <PostViewModel>(); foreach (var i in posts) { var posttags = await _postTagService.GetPostTags(i.Id); List <string> Tags = new List <string>(); foreach (var g in posttags) { Tags.Add(g.Title); } var nickname = (await _accountService.GetAccount(i.AuthorId)).Nickname; completePosts.Add(new PostViewModel { nickname = nickname, title = i.Title, text = i.Text, tags = Tags }); } return(Ok(completePosts)); } catch (Exception e) { return(BadRequest(e.ToString())); } }