switch to sqlite
This commit is contained in:
@@ -1,50 +1,19 @@
|
||||
using Xamarin.Forms;
|
||||
using System.Xml.Linq;
|
||||
using SQLite;
|
||||
|
||||
namespace Billing.Models
|
||||
{
|
||||
public class Category : BaseModel
|
||||
public class Category : IIdItem
|
||||
{
|
||||
private const string ICON_DEFAULT = "ic_default";
|
||||
private const long TRANSPARENT_COLOR = 0x00ffffffL;
|
||||
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int Id { get; set; }
|
||||
public CategoryType Type { get; set; }
|
||||
public string Icon { get; set; } = ICON_DEFAULT;
|
||||
public string Name { get; set; }
|
||||
public Color TintColor { get; set; } = Color.Transparent;
|
||||
public long TintColor { get; set; } = TRANSPARENT_COLOR;
|
||||
public int? ParentId { get; set; }
|
||||
|
||||
public override void OnXmlDeserialize(XElement node)
|
||||
{
|
||||
Id = Read(node, nameof(Id), 0);
|
||||
Type = (CategoryType)Read(node, nameof(Type), 0);
|
||||
Icon = Read(node, nameof(Icon), ICON_DEFAULT);
|
||||
Name = Read(node, nameof(Name), string.Empty);
|
||||
var color = Read(node, nameof(TintColor), string.Empty);
|
||||
if (!string.IsNullOrEmpty(color))
|
||||
{
|
||||
TintColor = Color.FromHex(color);
|
||||
}
|
||||
var parentId = Read(node, nameof(ParentId), -1);
|
||||
if (parentId >= 0)
|
||||
{
|
||||
ParentId = parentId;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnXmlSerialize(XElement node)
|
||||
{
|
||||
Write(node, nameof(Id), Id);
|
||||
Write(node, nameof(Type), (int)Type);
|
||||
Write(node, nameof(Icon), Icon);
|
||||
Write(node, nameof(Name), Name);
|
||||
if (TintColor != Color.Transparent)
|
||||
{
|
||||
Write(node, nameof(TintColor), TintColor.ToHex());
|
||||
}
|
||||
if (ParentId != null)
|
||||
{
|
||||
Write(node, nameof(ParentId), ParentId.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum CategoryType
|
||||
|
Reference in New Issue
Block a user