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

61 lines
1.4 KiB
C#

using Microsoft.Identity.Client;
using ServiceStationContracts.BindingModels;
using ServiceStationContracts.ViewModels;
using ServiceStationDataModels.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 ServiceStationsDataBaseImplement.Models
{
public class Executor : IExecutorModel {
public int Id { get; set; }
[Required]
public string Email { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[Required]
public string ExecutorFIO { get; set; } = string.Empty;
[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,
ExecutorFIO = model.ExecutorFIO
};
}
public void Update(ExecutorBindingModel? model) {
if (model== null) {
return;
}
Email = model.Email;
Password = model.Password;
ExecutorFIO = model.ExecutorFIO;
}
public ExecutorViewModel GetViewModel => new() {
Id = Id,
Email = Email,
Password = Password,
ExecutorFIO = ExecutorFIO
};
}
}