using SchoolContracts.BindingModel; using SchoolContracts.ViewModels; using SchoolDatabaseImplement.Models; using SchoolDataModels.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 SchoolDatabaseImplement.Models { public class Client : IClientModel { public int Id { get; private set; } [Required] public string ClientName { get; private set; } = string.Empty; [Required] public string ClientPhone { get; private set; } = string.Empty; [Required] public string ClientPassword { get; private set; } = string.Empty; [Required] public string ClientEmail { get; private set; } = string.Empty; [ForeignKey("ClientId")] public virtual List Circles { get; set; } = new(); public static Client? Create(ClientBindingModel model) { if (model == null) { return null; } return new() { Id = model.Id, ClientName= model.ClientName, ClientEmail = model.ClientEmail, ClientPassword = model.ClientPassword, ClientPhone= model.ClientPhone }; } public void Update(ClientBindingModel model) { if (model == null) { return; } ClientName = model.ClientName; ClientEmail = model.ClientEmail; ClientPassword = model.ClientPassword; ClientPhone = model.ClientPhone; } public ClientViewModel GetViewModel => new() { Id = Id, ClientName = ClientName, ClientEmail = ClientEmail, ClientPassword = ClientPassword, ClientPhone = ClientPhone }; } }