using ServiceStationContracts.BindingModels; using ServiceStationContracts.ViewModels; using ServiceStationDataModels; 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 Client : IClientModel { [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 Point { get; set; } public int ID { get; set; } public static Client? Create(ClientBindingModel? model) { if (model == null) { return null; } return new Client() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Password = model.Password, PhoneNumber = model.PhoneNumber, Login = model.Login, Point = model.Point, ID = model.ID }; } public static Client? Create(ClientViewModel model) { return new Client { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Password = model.Password, PhoneNumber = model.PhoneNumber, Login = model.Login, Point = model.Point, ID = model.ID }; } public void Update(ClientBindingModel model) { if (model == null) { return; } FirstName = model.FirstName; LastName = model.LastName; Email = model.Email; Password = model.Password; PhoneNumber = model.PhoneNumber; Login = model.Login; Point = model.Point; } public ClientViewModel GetViewModel => new() { FirstName = FirstName, LastName = LastName, Email = Email, Password = Password, PhoneNumber = PhoneNumber, Login = Login, Point = Point, ID = ID }; } }