PIbd22_Kuznetsov_A.V._Sewin.../SewingDresses/SewingDressesDatabaseImplement/Models/Implement.cs

60 lines
1.6 KiB
C#
Raw Normal View History

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;
using System.Text;
using System.Threading.Tasks;
namespace SewingDressesDatabaseImplement.Models
{
public class Implement : IImplementModel
{
public int Id { get; private set; }
[Required]
public string ImplementFIO { get; private set; } = string.Empty;
[Required]
public int WorkExperience { get; private set; }
[Required]
public string Password { get; private set; } = string.Empty;
[Required]
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;
}
}
}