ISEbd-22_Baygulov_A.A._Sush.../SushiBar/SushiBarDatabaseImplement/Implementer.cs

74 lines
2.1 KiB
C#
Raw Normal View History

2024-05-04 18:04:21 +04:00
using System;
using System.Collections.Generic;
2024-06-01 17:37:58 +04:00
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
2024-05-04 18:04:21 +04:00
using System.Linq;
using System.Text;
2024-06-01 17:37:58 +04:00
using System.Threading.Tasks;
2024-05-04 18:04:21 +04:00
using SushiBarContracts.BindingModels;
using SushiBarDatabaseImplement.Models;
2024-06-01 17:37:58 +04:00
using SushiBarContracts.ViewModels;
using System.Runtime.Serialization;
2024-05-04 18:04:21 +04:00
2024-06-01 17:37:58 +04:00
namespace SushiBarDataModels.Models
2024-05-04 18:04:21 +04:00
{
2024-06-01 17:37:58 +04:00
[DataContract]
public class Implementer : IImplementerModel
{
[DataMember]
public int Id { get; set; }
[DataMember]
[Required]
public string ImplementerFIO { get; set; } = string.Empty;
[DataMember]
[Required]
public string Password { get; set; } = string.Empty;
[DataMember]
[Required]
public int WorkExperience { get; set; }
[DataMember]
[Required]
public int Qualification { get; set; }
2024-05-04 18:04:21 +04:00
2024-06-01 17:37:58 +04:00
[ForeignKey("ImplementerId")]
public virtual List<Order> Order { get; set; } = new();
2024-05-04 18:04:21 +04:00
2024-06-01 17:37:58 +04:00
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
};
}
2024-05-04 18:04:21 +04:00
2024-06-01 17:37:58 +04:00
public void Update(ImplementerBindingModel model)
{
if (model == null)
{
return;
}
ImplementerFIO = model.ImplementerFIO;
Password = model.Password;
WorkExperience = model.WorkExperience;
Qualification = model.Qualification;
}
2024-05-04 18:04:21 +04:00
2024-06-01 17:37:58 +04:00
public ImplementerViewModel GetViewModel => new()
{
Id = Id,
ImplementerFIO = ImplementerFIO,
Password = Password,
WorkExperience = WorkExperience,
Qualification = Qualification
};
}
2024-05-04 18:04:21 +04:00
}