Fix some Build Issues, Renaming

This commit is contained in:
Qstick 2017-09-05 23:38:05 -04:00
parent 95051cbd63
commit a747c5f135
191 changed files with 16 additions and 16 deletions

View 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;
}
}
}