75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
|
using LawFirmContracts.BindingModels;
|
|||
|
using LawFirmContracts.ViewModels;
|
|||
|
using LawFirmDataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Xml.Linq;
|
|||
|
|
|||
|
namespace LawFirmFileImplement.Models
|
|||
|
{
|
|||
|
public class Blank : IBlankModel
|
|||
|
{
|
|||
|
public string BlankName { get; private set; } = String.Empty;
|
|||
|
|
|||
|
public double Cost { get; set; }
|
|||
|
|
|||
|
public int Id { get; private set; }
|
|||
|
|
|||
|
public static Blank? Create(BlankBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Blank()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
BlankName = model.BlankName,
|
|||
|
Cost = model.Cost
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public static Blank? Create(XElement element)
|
|||
|
{
|
|||
|
if (element == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Blank()
|
|||
|
{
|
|||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|||
|
BlankName = element.Element("BlankName")!.Value,
|
|||
|
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(BlankBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
BlankName = model.BlankName;
|
|||
|
Cost = model.Cost;
|
|||
|
}
|
|||
|
public BlankViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
BlankName = BlankName,
|
|||
|
Cost = Cost
|
|||
|
};
|
|||
|
|
|||
|
public XElement GetXElement => new(
|
|||
|
"Blank",
|
|||
|
new XAttribute("Id", Id),
|
|||
|
new XElement("BlankName", BlankName),
|
|||
|
new XElement("Cost", Cost.ToString())
|
|||
|
);
|
|||
|
|
|||
|
}
|
|||
|
}
|