Fixed: Improved message when a conflicting slug is added

This commit is contained in:
Mark McDowall 2017-05-17 21:42:57 -07:00
parent cf7ce9804f
commit edf549d0fd
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0
1 changed files with 16 additions and 4 deletions

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Tv
private readonly ISeriesService _seriesService; private readonly ISeriesService _seriesService;
public SeriesTitleSlugValidator(ISeriesService seriesService) public SeriesTitleSlugValidator(ISeriesService seriesService)
: base("Title slug is in use by another series with a similar name") : base("Title slug '{slug}' is in use by series '{seriesTitle}'")
{ {
_seriesService = seriesService; _seriesService = seriesService;
} }
@ -21,10 +21,22 @@ namespace NzbDrone.Core.Tv
dynamic instance = context.ParentContext.InstanceToValidate; dynamic instance = context.ParentContext.InstanceToValidate;
var instanceId = (int)instance.Id; var instanceId = (int)instance.Id;
var slug = context.PropertyValue.ToString();
return !_seriesService.GetAllSeries().Where(s => s.TitleSlug.IsNotNullOrWhiteSpace()) var conflictingSeries = _seriesService.GetAllSeries()
.ToList() .FirstOrDefault(s => s.TitleSlug.IsNotNullOrWhiteSpace() &&
.Exists(s => s.TitleSlug.Equals(context.PropertyValue.ToString()) && s.Id != instanceId); s.TitleSlug.Equals(context.PropertyValue.ToString()) &&
s.Id != instanceId);
if (conflictingSeries == null)
{
return true;
}
context.MessageFormatter.AppendArgument("slug", slug);
context.MessageFormatter.AppendArgument("seriesTitle", conflictingSeries.Title);
return false;
} }
} }
} }