75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
using FurnitureAssemblyContracts.BindingModels;
|
|
using FurnitureAssemblyContracts.ViewModels;
|
|
using FurnitureAssemblyDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Linq;
|
|
|
|
namespace FurnitureAssemblyFileImplement.Models
|
|
{
|
|
public class Komment : IKommentModel
|
|
{
|
|
public int Id { get; private set; }
|
|
|
|
public string WorkPieceName { get; private set; } = string.Empty;
|
|
|
|
public double Cost { get; set; }
|
|
|
|
public static Komment? Create(KommentBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new Komment()
|
|
{
|
|
Id = model.Id,
|
|
WorkPieceName = model.WorkPieceName,
|
|
Cost = model.Cost
|
|
};
|
|
}
|
|
|
|
public static Komment? Create(XElement element)
|
|
{
|
|
if (element == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new Komment()
|
|
{
|
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
WorkPieceName = element.Element("WorkPieceName")!.Value,
|
|
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
|
};
|
|
}
|
|
|
|
public void Update(KommentBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
WorkPieceName = model.WorkPieceName;
|
|
Cost = model.Cost;
|
|
}
|
|
|
|
public KommentViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
WorkPieceName = WorkPieceName,
|
|
Cost = Cost
|
|
};
|
|
|
|
public XElement GetXElement => new("WorkPiece",
|
|
new XAttribute("Id", Id),
|
|
new XElement("WorkPieceName", WorkPieceName),
|
|
new XElement("Cost", Cost.ToString()));
|
|
}
|
|
}
|