mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-10 23:33:38 -07:00
Initial Commit Rework
This commit is contained in:
parent
74a4cc048c
commit
95051cbd63
2483 changed files with 101351 additions and 111396 deletions
57
src/Sonarr.Api.V3/Profiles/Language/LanguageProfileModule.cs
Normal file
57
src/Sonarr.Api.V3/Profiles/Language/LanguageProfileModule.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using System.Collections.Generic;
|
||||
using FluentValidation;
|
||||
using NzbDrone.Core.Profiles.Languages;
|
||||
using Lidarr.Http;
|
||||
|
||||
namespace Lidarr.Api.V3.Profiles.Language
|
||||
{
|
||||
public class LanguageProfileModule : LidarrRestModule<LanguageProfileResource>
|
||||
{
|
||||
private readonly ILanguageProfileService _profileService;
|
||||
|
||||
public LanguageProfileModule(ILanguageProfileService profileService)
|
||||
{
|
||||
_profileService = profileService;
|
||||
SharedValidator.RuleFor(c => c.Name).NotEmpty();
|
||||
SharedValidator.RuleFor(c => c.Cutoff).NotNull();
|
||||
SharedValidator.RuleFor(c => c.Languages).MustHaveAllowedLanguage();
|
||||
|
||||
GetResourceAll = GetAll;
|
||||
GetResourceById = GetById;
|
||||
UpdateResource = Update;
|
||||
CreateResource = Create;
|
||||
DeleteResource = DeleteProfile;
|
||||
}
|
||||
|
||||
private int Create(LanguageProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
model = _profileService.Add(model);
|
||||
return model.Id;
|
||||
}
|
||||
|
||||
private void DeleteProfile(int id)
|
||||
{
|
||||
_profileService.Delete(id);
|
||||
}
|
||||
|
||||
private void Update(LanguageProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
|
||||
_profileService.Update(model);
|
||||
}
|
||||
|
||||
private LanguageProfileResource GetById(int id)
|
||||
{
|
||||
return _profileService.Get(id).ToResource();
|
||||
}
|
||||
|
||||
private List<LanguageProfileResource> GetAll()
|
||||
{
|
||||
var profiles = _profileService.All().ToResource();
|
||||
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue