mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Store QualityPofile properly
This commit is contained in:
parent
e9b9e63f7a
commit
b6ac7638a1
9 changed files with 80 additions and 10 deletions
43
NzbDrone.Core/Datastore/Converters/QualityIntConverter.cs
Normal file
43
NzbDrone.Core/Datastore/Converters/QualityIntConverter.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using Marr.Data.Converters;
|
||||
using Marr.Data.Mapping;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Converters
|
||||
{
|
||||
public class QualityIntConverter : IConverter
|
||||
{
|
||||
public object FromDB(ColumnMap map, object dbValue)
|
||||
{
|
||||
if (dbValue == DBNull.Value)
|
||||
{
|
||||
return Quality.Unknown;
|
||||
}
|
||||
|
||||
var val = Convert.ToInt32(dbValue);
|
||||
|
||||
return (Quality)val;
|
||||
}
|
||||
|
||||
public object ToDB(object clrValue)
|
||||
{
|
||||
if(clrValue == null) return 0;
|
||||
|
||||
if(clrValue as Quality == null)
|
||||
{
|
||||
throw new InvalidOperationException("Attempted to save a quality that isn't really a quality");
|
||||
}
|
||||
|
||||
var quality = clrValue as Quality;
|
||||
return (int)quality;
|
||||
}
|
||||
|
||||
public Type DbType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(int);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue