2023-03-06 09:07:54 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2023-06-03 03:05:40 +04:00
|
|
|
|
using System.Runtime.Serialization;
|
2023-03-06 09:07:54 +04:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-06-03 03:05:40 +04:00
|
|
|
|
using System.Xml.Linq;
|
2023-03-06 09:07:54 +04:00
|
|
|
|
using TravelCompanyContracts.BindingModels;
|
|
|
|
|
using TravelCompanyContracts.ViewModels;
|
2023-06-03 03:05:40 +04:00
|
|
|
|
using TravelCompanyDataModels.Models;
|
2023-03-06 09:07:54 +04:00
|
|
|
|
|
|
|
|
|
namespace TravelCompanyFileImplement.Models
|
|
|
|
|
{
|
2023-06-03 03:05:40 +04:00
|
|
|
|
[DataContract]
|
2023-03-06 09:07:54 +04:00
|
|
|
|
public class Condition : IConditionModel
|
|
|
|
|
{
|
2023-06-03 03:05:40 +04:00
|
|
|
|
[DataMember]
|
2023-03-06 09:07:54 +04:00
|
|
|
|
public int Id { get; private set; }
|
2023-06-03 03:05:40 +04:00
|
|
|
|
[DataMember]
|
2023-03-06 09:07:54 +04:00
|
|
|
|
public string ConditionName { get; private set; } = string.Empty;
|
2023-06-03 03:05:40 +04:00
|
|
|
|
[DataMember]
|
2023-03-06 09:07:54 +04:00
|
|
|
|
public double Cost { get; set; }
|
|
|
|
|
public static Condition? Create(ConditionBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Condition()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
ConditionName = model.ConditionName,
|
|
|
|
|
Cost = model.Cost
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public static Condition? Create(XElement element)
|
|
|
|
|
{
|
|
|
|
|
if (element == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Condition()
|
|
|
|
|
{
|
|
|
|
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
|
|
|
ConditionName = element.Element("ConditionName")!.Value,
|
|
|
|
|
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(ConditionBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ConditionName = model.ConditionName;
|
|
|
|
|
Cost = model.Cost;
|
|
|
|
|
}
|
|
|
|
|
public ConditionViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
ConditionName = ConditionName,
|
|
|
|
|
Cost = Cost
|
|
|
|
|
};
|
|
|
|
|
public XElement GetXElement => new("Condition",
|
|
|
|
|
new XAttribute("Id", Id),
|
|
|
|
|
new XElement("ConditionName", ConditionName),
|
|
|
|
|
new XElement("Cost", Cost.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|