model
This commit is contained in:
31
Billing.Shared/Models/Category.cs
Normal file
31
Billing.Shared/Models/Category.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Billing.Models;
|
||||
|
||||
public class Category : BaseModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int? ParentId { get; set; }
|
||||
|
||||
public override void OnXmlDeserialize(XElement node)
|
||||
{
|
||||
Id = Read(node, nameof(Id), 0);
|
||||
Name = Read(node, nameof(Name), string.Empty);
|
||||
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(Name), Name);
|
||||
if (ParentId != null)
|
||||
{
|
||||
Write(node, nameof(ParentId), ParentId.Value);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user