features/add-authors-table #17

Merged
jtom38 merged 5 commits from features/add-authors-table into main 2023-08-04 23:09:45 -07:00
2 changed files with 14 additions and 4 deletions
Showing only changes of commit a3085bb27f - Show all commits

View File

@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newsbot.Collector.Domain.Dto;
using Newsbot.Collector.Domain.Entities;
using Newsbot.Collector.Domain.Interfaces;
using Newsbot.Collector.Domain.Results;
@ -15,11 +16,13 @@ public class ArticlesController : ControllerBase
//private readonly ILogger<ArticlesController> _logger;
private readonly IArticlesRepository _articles;
private readonly ISourcesRepository _sources;
private readonly IAuthorTable _author;
public ArticlesController(IArticlesRepository articles, ISourcesRepository sources)
public ArticlesController(IArticlesRepository articles, ISourcesRepository sources, IAuthorTable author)
{
_articles = articles;
_sources = sources;
_author = author;
}
[HttpGet(Name = "GetArticles")]
@ -59,11 +62,13 @@ public class ArticlesController : ControllerBase
{
var item = _articles.GetById(id);
var sourceItem = _sources.GetById(item.SourceId);
var author = _author.GetBySourceIdAndNameAsync(sourceItem.Id, sourceItem.Name);
author.Wait();
return new OkObjectResult(new ArticleDetailsResult
{
IsSuccessful = true,
Item = ArticleDetailsDto.Convert(item, sourceItem)
Item = ArticleDetailsDto.Convert(item, sourceItem, author.Result)
});
}

View File

@ -32,12 +32,15 @@ public class DiscordNotificationJobTest
PubDate = DateTime.Now,
Thumbnail = "https://cdn.arstechnica.net/wp-content/uploads/2023/03/GettyImages-944827400-800x534.jpg",
Description = "Please work",
AuthorName = "No one knows"
},
new IconEntity()
{
Id = Guid.NewGuid(),
FileName = "https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png"
}, new AuthorEntity
{
Id = Guid.NewGuid(),
Name = "test"
});
webhookClient.SendMessage(msg);
}
@ -59,7 +62,6 @@ public class DiscordNotificationJobTest
Thumbnail =
"https://cdn.arstechnica.net/wp-content/uploads/2023/03/GettyImages-944827400-800x534.jpg",
Description = "Please work",
AuthorName = "No one knows",
CodeIsCommit = true
},
new SourceEntity
@ -82,6 +84,9 @@ public class DiscordNotificationJobTest
{
CodeAllowCommits = false,
CodeAllowReleases = true
}, new AuthorEntity
{
Name = "a"
});
Assert.Fail("Expected a error to come back.");
}