84 lines
2.2 KiB
C#
84 lines
2.2 KiB
C#
using SewingDressesContracts.BindingModels;
|
|
using SewingDressesContracts.ViewModels;
|
|
using SewingDressesDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http.Headers;
|
|
using System.Runtime.Serialization;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Linq;
|
|
|
|
namespace SewingDressesFileImplement.Models
|
|
{
|
|
[DataContract]
|
|
public class Implement : IImplementModel
|
|
{
|
|
[DataMember]
|
|
public int Id { get; set; }
|
|
[DataMember]
|
|
public string ImplementFIO { get; set; } = string.Empty;
|
|
[DataMember]
|
|
public string Password { get; set; } = string.Empty;
|
|
[DataMember]
|
|
public int WorkExperience { get; set; }
|
|
[DataMember]
|
|
public int Qualification { get; set; }
|
|
public static Implement? Create(ImplementBindingModel? model)
|
|
{
|
|
if (model == null) return null;
|
|
return new Implement
|
|
{
|
|
Id = model.Id,
|
|
ImplementFIO = model.ImplementFIO,
|
|
Password = model.Password,
|
|
WorkExperience = model.WorkExperience,
|
|
Qualification = model.Qualification,
|
|
};
|
|
}
|
|
public static Implement? Create(XElement element)
|
|
{
|
|
if (element == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Implement()
|
|
{
|
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
ImplementFIO = element.Element("ImplementFIO")!.Value,
|
|
Password = element.Element("Password")!.Value,
|
|
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
|
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value)
|
|
};
|
|
}
|
|
public XElement GetXElement => new("Implement",
|
|
new XAttribute("Id", Id),
|
|
new XElement("ImplementFIO", ImplementFIO),
|
|
new XElement("Password", Password),
|
|
new XElement("Qualification", Qualification.ToString()),
|
|
new XElement("WorkExperience", WorkExperience.ToString())
|
|
);
|
|
public ImplementViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ImplementFIO = ImplementFIO,
|
|
Password = Password,
|
|
WorkExperience = WorkExperience,
|
|
Qualification = Qualification
|
|
};
|
|
public void Update(ImplementBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
ImplementFIO = model.ImplementFIO;
|
|
Password = model.Password;
|
|
WorkExperience = model.WorkExperience;
|
|
Qualification = model.Qualification;
|
|
}
|
|
|
|
}
|
|
}
|