2024-05-26 13:40:22 +04:00
|
|
|
|
using SewingDressesContracts.BindingModels;
|
|
|
|
|
using SewingDressesContracts.ViewModels;
|
|
|
|
|
using SewingDressesDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.Linq;
|
2024-06-22 21:11:56 +04:00
|
|
|
|
using System.Runtime.Serialization;
|
2024-05-26 13:40:22 +04:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SewingDressesDatabaseImplement.Models
|
|
|
|
|
{
|
2024-06-22 21:11:56 +04:00
|
|
|
|
[DataContract]
|
2024-05-26 13:40:22 +04:00
|
|
|
|
public class Implement : IImplementModel
|
|
|
|
|
{
|
2024-06-22 21:11:56 +04:00
|
|
|
|
[DataMember]
|
2024-05-26 13:40:22 +04:00
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
[Required]
|
2024-06-22 21:11:56 +04:00
|
|
|
|
[DataMember]
|
2024-05-26 13:40:22 +04:00
|
|
|
|
public string ImplementFIO { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
2024-06-22 21:11:56 +04:00
|
|
|
|
[DataMember]
|
2024-05-26 13:40:22 +04:00
|
|
|
|
public int WorkExperience { get; private set; }
|
|
|
|
|
[Required]
|
2024-06-22 21:11:56 +04:00
|
|
|
|
[DataMember]
|
2024-05-26 13:40:22 +04:00
|
|
|
|
public string Password { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
2024-06-22 21:11:56 +04:00
|
|
|
|
[DataMember]
|
2024-05-26 13:40:22 +04:00
|
|
|
|
public int Qualification { get; private set; }
|
|
|
|
|
[ForeignKey("ImplementId")]
|
|
|
|
|
public virtual List<Order>? Orders { get; set; } = new();
|
|
|
|
|
public static Implement? Create(ImplementBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
return null;
|
|
|
|
|
return new Implement
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
ImplementFIO = model.ImplementFIO,
|
|
|
|
|
WorkExperience = model.WorkExperience,
|
|
|
|
|
Password = model.Password,
|
|
|
|
|
Qualification = model.Qualification,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public ImplementViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
ImplementFIO = ImplementFIO,
|
|
|
|
|
WorkExperience = WorkExperience,
|
|
|
|
|
Password = Password,
|
|
|
|
|
Qualification = Qualification
|
|
|
|
|
};
|
|
|
|
|
public void Update(ImplementBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null) return;
|
|
|
|
|
ImplementFIO = model.ImplementFIO;
|
|
|
|
|
WorkExperience = model.WorkExperience;
|
|
|
|
|
Password = model.Password;
|
|
|
|
|
Qualification = model.Qualification;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|