complete account page

This commit is contained in:
2022-03-02 17:31:49 +08:00
parent aa38e186c7
commit 51f8e4f2e8
26 changed files with 547 additions and 76 deletions

View File

@ -161,11 +161,12 @@ namespace Billing.Models
public override string ToString()
{
XDocument xdoc = ToXml();
using MemoryStream ms = new();
using StreamWriter writer = new(ms, Encoding.UTF8);
xdoc.Save(writer, SaveOptions.DisableFormatting);
writer.Flush();
//using StreamWriter writer = new(ms, Encoding.UTF8);
//XDocument xdoc = ToXml();
//xdoc.Save(writer, SaveOptions.DisableFormatting);
//writer.Flush();
SaveToStream(ms);
ms.Seek(0, SeekOrigin.Begin);
using StreamReader reader = new(ms, Encoding.UTF8);
return reader.ReadToEnd();

View File

@ -3,7 +3,7 @@ using System.Xml.Linq;
namespace Billing.Models
{
public class Billing : BaseModel
public class Bill : BaseModel
{
public decimal Amount { get; set; }
public string Name { get; set; }

View File

@ -5,6 +5,7 @@ namespace Billing.Models
public class Category : BaseModel
{
public int Id { get; set; }
public CategoryType Type { get; set; }
public string Icon { get; set; } = ICON_DEFAULT;
public string Name { get; set; }
public int? ParentId { get; set; }
@ -12,6 +13,7 @@ namespace Billing.Models
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 parentId = Read(node, nameof(ParentId), -1);
@ -24,6 +26,7 @@ namespace Billing.Models
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 (ParentId != null)
@ -32,4 +35,10 @@ namespace Billing.Models
}
}
}
public enum CategoryType
{
Spending,
Income
}
}