misc renames

This commit is contained in:
Collin M. Barrett 2019-07-13 12:40:37 -05:00
parent 185e37863f
commit a3cb9fc0a5
5 changed files with 17 additions and 17 deletions

View file

@ -1,6 +1,6 @@
namespace FilterLists.Agent.Core.Urls
{
public enum FilterListsEntity
public enum Entity
{
License,
FilterList,

View file

@ -8,19 +8,19 @@ namespace FilterLists.Agent.Core.Urls
{
public class EntityUrl
{
public EntityUrl(FilterListsEntity filterListsEntity, int id, Uri viewUrl)
public EntityUrl(Entity entity, int id, Uri url)
{
FilterListsEntity = filterListsEntity;
Entity = entity;
Id = id;
ViewUrl = viewUrl;
Url = url;
}
public FilterListsEntity FilterListsEntity { get; }
public Entity Entity { get; }
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public int Id { [UsedImplicitly] get; }
public Uri ViewUrl { get; }
public Uri Url { get; }
public List<string> ValidationMessages { get; } = new List<string>();

View file

@ -27,7 +27,7 @@ protected override string Handle(Command request)
{
var body = new StringBuilder();
body.Append(IssueHeader);
var entityInvalidUrlGroups = request.InvalidEntityUrls.GroupBy(i => i.FilterListsEntity);
var entityInvalidUrlGroups = request.InvalidEntityUrls.GroupBy(i => i.Entity);
foreach (var entityInvalidUrls in entityInvalidUrlGroups)
{
body.Append(
@ -36,7 +36,7 @@ protected override string Handle(Command request)
foreach (var invalidUrl in entityInvalidUrls)
{
body.Append(
$"<li><a href=\"{invalidUrl.ViewUrl.OriginalString}\">{invalidUrl.ViewUrl.OriginalString}</a>");
$"<li><a href=\"{invalidUrl.Url.OriginalString}\">{invalidUrl.Url.OriginalString}</a>");
body.Append("<ul>");
foreach (var message in invalidUrl.ValidationMessages)
body.Append($"<li>{message}</li>");

View file

@ -13,14 +13,14 @@ namespace FilterLists.Agent.Infrastructure.FilterListsApi
[UsedImplicitly]
public class EntityUrlRepository : IEntityUrlRepository
{
private static readonly Dictionary<string, (string, FilterListsEntity)> EndpointAndEntityByDto =
new Dictionary<string, (string, FilterListsEntity)>
private static readonly Dictionary<string, (string, Entity)> EndpointAndEntityByDto =
new Dictionary<string, (string, Entity)>
{
{nameof(LicenseUrls), ("licenses", FilterListsEntity.License)},
{nameof(ListUrls), ("lists", FilterListsEntity.FilterList)},
{nameof(MaintainerUrls), ("maintainers", FilterListsEntity.Maintainer)},
{nameof(SoftwareUrls), ("software", FilterListsEntity.Software)},
{nameof(SyntaxUrls), ("syntaxes", FilterListsEntity.Syntax)}
{nameof(LicenseUrls), ("licenses", Entity.License)},
{nameof(ListUrls), ("lists", Entity.FilterList)},
{nameof(MaintainerUrls), ("maintainers", Entity.Maintainer)},
{nameof(SoftwareUrls), ("software", Entity.Software)},
{nameof(SyntaxUrls), ("syntaxes", Entity.Syntax)}
};
private readonly IFilterListsApiClient _apiClient;
@ -51,7 +51,7 @@ private async Task<IEnumerable<EntityUrl>> GetAllForEntity<TModel>(CancellationT
var id = (int)propertyInfos.First(p => p.Name == nameof(LicenseUrls.Id)).GetValue(e);
return propertyInfos.Where(p => p.GetValue(e) != null && p.PropertyType == typeof(Uri)).Select(p =>
new EntityUrl(EndpointAndEntityByDto[typeof(TModel).Name].Item2, id, (Uri)p.GetValue(e)));
}).GroupBy(e => e.ViewUrl).Select(e => e.First());
}).GroupBy(e => e.Url).Select(e => e.First());
}
}
}

View file

@ -28,7 +28,7 @@ public UrlValidator(HttpClient httpClient, ILogger<UrlValidator> logger)
public async Task<EntityUrl> ValidateAsync(EntityUrl entityUrl, CancellationToken cancellationToken)
{
var url = entityUrl.ViewUrl;
var url = entityUrl.Url;
try
{
using var response =