mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-21 22:05:43 -04:00
Reformat and apply Stylecop rules
This commit is contained in:
@@ -23,12 +23,11 @@ namespace NzbDrone.Core.CustomFormats
|
||||
void Delete(int id);
|
||||
}
|
||||
|
||||
|
||||
public class CustomFormatService : ICustomFormatService, IHandle<ApplicationStartedEvent>
|
||||
{
|
||||
private readonly ICustomFormatRepository _formatRepository;
|
||||
private IProfileService _profileService;
|
||||
private readonly IHistoryService _historyService;
|
||||
private IProfileService _profileService;
|
||||
|
||||
public IProfileService ProfileService
|
||||
{
|
||||
@@ -49,8 +48,10 @@ namespace NzbDrone.Core.CustomFormats
|
||||
|
||||
public static Dictionary<int, CustomFormat> AllCustomFormats;
|
||||
|
||||
public CustomFormatService(ICustomFormatRepository formatRepository, ICacheManager cacheManager,
|
||||
IContainer container, IHistoryService historyService,
|
||||
public CustomFormatService(ICustomFormatRepository formatRepository,
|
||||
ICacheManager cacheManager,
|
||||
IContainer container,
|
||||
IHistoryService historyService,
|
||||
Logger logger)
|
||||
{
|
||||
_formatRepository = formatRepository;
|
||||
@@ -79,6 +80,7 @@ namespace NzbDrone.Core.CustomFormats
|
||||
_formatRepository.Delete(ret);
|
||||
throw;
|
||||
}
|
||||
|
||||
_cache.Clear();
|
||||
return ret;
|
||||
}
|
||||
@@ -90,27 +92,36 @@ namespace NzbDrone.Core.CustomFormats
|
||||
{
|
||||
//First history:
|
||||
var historyRepo = _container.Resolve<IHistoryRepository>();
|
||||
DeleteInRepo(historyRepo, h => h.Quality.CustomFormats, (h, f) =>
|
||||
{
|
||||
h.Quality.CustomFormats = f;
|
||||
return h;
|
||||
}, id);
|
||||
DeleteInRepo(historyRepo,
|
||||
h => h.Quality.CustomFormats,
|
||||
(h, f) =>
|
||||
{
|
||||
h.Quality.CustomFormats = f;
|
||||
return h;
|
||||
},
|
||||
id);
|
||||
|
||||
//Then Blacklist:
|
||||
var blacklistRepo = _container.Resolve<IBlacklistRepository>();
|
||||
DeleteInRepo(blacklistRepo, h => h.Quality.CustomFormats, (h, f) =>
|
||||
{
|
||||
h.Quality.CustomFormats = f;
|
||||
return h;
|
||||
}, id);
|
||||
DeleteInRepo(blacklistRepo,
|
||||
h => h.Quality.CustomFormats,
|
||||
(h, f) =>
|
||||
{
|
||||
h.Quality.CustomFormats = f;
|
||||
return h;
|
||||
},
|
||||
id);
|
||||
|
||||
//Then MovieFiles:
|
||||
var moviefileRepo = _container.Resolve<IMediaFileRepository>();
|
||||
DeleteInRepo(moviefileRepo, h => h.Quality.CustomFormats, (h, f) =>
|
||||
{
|
||||
h.Quality.CustomFormats = f;
|
||||
return h;
|
||||
}, id);
|
||||
DeleteInRepo(moviefileRepo,
|
||||
h => h.Quality.CustomFormats,
|
||||
(h, f) =>
|
||||
{
|
||||
h.Quality.CustomFormats = f;
|
||||
return h;
|
||||
},
|
||||
id);
|
||||
|
||||
//Then Profiles
|
||||
ProfileService.DeleteCustomFormat(id);
|
||||
@@ -127,8 +138,11 @@ namespace NzbDrone.Core.CustomFormats
|
||||
_cache.Clear();
|
||||
}
|
||||
|
||||
private void DeleteInRepo<TModel>(IBasicRepository<TModel> repository, Func<TModel, List<CustomFormat>> queryFunc,
|
||||
Func<TModel, List<CustomFormat>, TModel> updateFunc, int customFormatId) where TModel : ModelBase, new()
|
||||
private void DeleteInRepo<TModel>(IBasicRepository<TModel> repository,
|
||||
Func<TModel, List<CustomFormat>> queryFunc,
|
||||
Func<TModel, List<CustomFormat>, TModel> updateFunc,
|
||||
int customFormatId)
|
||||
where TModel : ModelBase, new()
|
||||
{
|
||||
var allItems = repository.All();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user