This commit is contained in:
dyakonovr
2024-05-02 23:14:39 +04:00
parent b4081cb911
commit 227f8c1d23
46 changed files with 2418 additions and 73 deletions

View File

@@ -0,0 +1,78 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models
{
public class Implementer : IImplementerModel
{
public int Id { get; private set; }
public string ImplementerFIO { get; private set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public int Qualification { get; set; } = 0;
public int WorkExperience { get; set; } = 0;
public static Implementer? Create(ImplementerBindingModel model)
{
if (model == null)
{
return null;
}
return new Implementer()
{
Id = model.Id,
ImplementerFIO = model.ImplementerFIO,
Password = model.Password,
WorkExperience = model.WorkExperience,
Qualification = model.Qualification
};
}
public void Update(ImplementerBindingModel model)
{
if (model == null)
{
return;
}
ImplementerFIO = model.ImplementerFIO;
Password = model.Password;
WorkExperience = model.WorkExperience;
Qualification = model.Qualification;
}
public ImplementerViewModel GetViewModel => new()
{
Id = Id,
ImplementerFIO = ImplementerFIO,
Password = Password,
WorkExperience = WorkExperience,
Qualification = Qualification
};
public static Implementer? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Implementer()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
Password = element.Element("Password")!.Value,
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value)
};
}
public XElement GetXElement => new("Implementer",
new XAttribute("Id", Id),
new XElement("ImplementerFIO", ImplementerFIO),
new XElement("Password", Password),
new XElement("Qualification", Qualification.ToString()),
new XElement("WorkExperience", WorkExperience.ToString())
);
}
}

View File

@@ -15,6 +15,7 @@ namespace SoftwareInstallationFileImplement.Models
{
public int ClientId { get; private set; }
public int PackageId { get; private set; }
public int? ImplementerId { get; set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@@ -35,6 +36,7 @@ namespace SoftwareInstallationFileImplement.Models
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
ImplementerId = model.ImplementerId,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
};
@@ -53,6 +55,7 @@ namespace SoftwareInstallationFileImplement.Models
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null)
};
@@ -81,6 +84,7 @@ namespace SoftwareInstallationFileImplement.Models
PackageId = PackageId,
ClientId = ClientId,
Count = Count,
ImplementerId = ImplementerId,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
@@ -91,6 +95,7 @@ namespace SoftwareInstallationFileImplement.Models
new XElement("PackageId", PackageId.ToString()),
new XElement("ClientId", ClientId.ToString()),
new XElement("Count", Count.ToString()),
new XElement("ImplementerId", ImplementerId.ToString()),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),
new XElement("DateCreate", DateCreate.ToString()),