Gismatullin.ISEbd-21.STO.Co.../ServiceStation/ServiceStationsDataBaseImplement/Models/Executor.cs

61 lines
1.3 KiB
C#
Raw Normal View History

2024-08-10 18:43:15 +04:00
using Microsoft.Identity.Client;
using ServiceStationContracts.BindingModels;
2024-04-30 20:55:37 +04:00
using ServiceStationContracts.ViewModels;
using ServiceStationDataModels.Models;
2024-04-30 20:55:37 +04:00
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
2024-08-10 18:43:15 +04:00
using System.ComponentModel.DataAnnotations.Schema;
2024-04-30 20:55:37 +04:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceStationsDataBaseImplement.Models
{
2024-08-10 18:43:15 +04:00
public class Executor : IExecutorModel {
2024-04-30 20:55:37 +04:00
2024-08-10 18:43:15 +04:00
public int Id { get; set; }
[Required]
public string Email { get; set; } = string.Empty;
2024-04-30 20:55:37 +04:00
2024-08-10 18:43:15 +04:00
[Required]
public string Password { get; set; } = string.Empty;
[Required]
2024-08-12 17:52:19 +04:00
public string FIO { get; set; } = string.Empty;
2024-08-10 18:43:15 +04:00
[ForeignKey("ExecutorId")]
public virtual List<Work> Works { get; set; } = new();
public static Executor? Create(ExecutorBindingModel? model) {
if (model == null) {
return null;
}
return new Executor() {
Id = model.Id,
Email = model.Email,
Password = model.Password,
2024-08-12 17:52:19 +04:00
FIO = model.FIO
2024-08-10 18:43:15 +04:00
};
}
public void Update(ExecutorBindingModel? model) {
if (model== null) {
return;
}
Email = model.Email;
Password = model.Password;
2024-08-12 17:52:19 +04:00
FIO = model.FIO;
2024-08-10 18:43:15 +04:00
}
public ExecutorViewModel GetViewModel => new() {
Id = Id,
Email = Email,
Password = Password,
2024-08-12 17:52:19 +04:00
FIO = FIO
2024-08-10 18:43:15 +04:00
};
}
2024-04-30 20:55:37 +04:00
}