2023-03-09 12:31:36 +04:00
|
|
|
|
using SecureShopContracts.BindingModels;
|
|
|
|
|
using SecureShopContracts.ViewModels;
|
|
|
|
|
using SecureShopDataModels.Models;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
2023-04-06 14:17:27 +04:00
|
|
|
|
namespace SecureShopDataBaseImplement.Models
|
2023-03-09 12:31:36 +04:00
|
|
|
|
{
|
|
|
|
|
public class Facilities : IFacilitiesModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
public string FacilitiesName { get; private set; } = string.Empty;
|
|
|
|
|
public double Cost { get; set; }
|
|
|
|
|
|
|
|
|
|
public static Facilities? Create(FacilitiesBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Facilities()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
FacilitiesName = model.FacilitiesName,
|
|
|
|
|
Cost = model.Cost
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Facilities? Create(XElement element)
|
|
|
|
|
{
|
|
|
|
|
if (element == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Facilities()
|
|
|
|
|
{
|
|
|
|
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
|
|
|
FacilitiesName = element.Element("FacilitiesName")!.Value,
|
|
|
|
|
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(FacilitiesBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
FacilitiesName = model.FacilitiesName;
|
|
|
|
|
Cost = model.Cost;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FacilitiesViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
FacilitiesName = FacilitiesName,
|
|
|
|
|
Cost = Cost
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public XElement GetXElement => new("Facilities",new XAttribute("Id", Id), new XElement("FacilitiesName", FacilitiesName), new XElement("Cost", Cost.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|