86 lines
2.5 KiB
C#
86 lines
2.5 KiB
C#
using ServiceStationContracts.BindingModels;
|
|
using ServiceStationContracts.ViewModels;
|
|
using ServiceStationDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ServiceStationsDataBaseImplement.Models
|
|
{
|
|
public class Executor : IExecutorModel
|
|
{
|
|
[Required]
|
|
public string FirstName { get; set; } = string.Empty;
|
|
[Required]
|
|
public string LastName { get; set; } = string.Empty;
|
|
[Required]
|
|
public string Email { get; set; } = string.Empty;
|
|
[Required]
|
|
public string Password { get; set; } = string.Empty;
|
|
[Required]
|
|
public string PhoneNumber { get; set; } = string.Empty;
|
|
[Required]
|
|
public string Login { get; set; } = string.Empty;
|
|
[Required]
|
|
public int Id { get; set; }
|
|
public static Executor? Create(ExecutorBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Executor()
|
|
{
|
|
FirstName = model.FirstName,
|
|
LastName = model.LastName,
|
|
Email = model.Email,
|
|
Password = model.Password,
|
|
PhoneNumber = model.PhoneNumber,
|
|
Login = model.Login,
|
|
Id = model.Id
|
|
|
|
};
|
|
}
|
|
public static Executor? Create(ExecutorViewModel model)
|
|
{
|
|
return new Executor
|
|
{
|
|
FirstName = model.FirstName,
|
|
LastName = model.LastName,
|
|
Email = model.Email,
|
|
Password = model.Password,
|
|
PhoneNumber = model.PhoneNumber,
|
|
Login = model.Login,
|
|
Id = model.Id
|
|
};
|
|
}
|
|
public void Update(ExecutorBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
FirstName = model.FirstName;
|
|
LastName = model.LastName;
|
|
Email = model.Email;
|
|
Password = model.Password;
|
|
PhoneNumber = model.PhoneNumber;
|
|
Login = model.Login;
|
|
|
|
}
|
|
public ExecutorViewModel GetViewModel => new()
|
|
{
|
|
FirstName = FirstName,
|
|
LastName = LastName,
|
|
Email = Email,
|
|
Password = Password,
|
|
PhoneNumber = PhoneNumber,
|
|
Login = Login,
|
|
Id = Id
|
|
};
|
|
}
|
|
}
|