using CarShowroomDataModels.Views; using CarShowroomDataModels.Models; using Microsoft.EntityFrameworkCore; 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 CarShowroomDatabaseStorage.Entities { [Table("employee")] [Index(nameof(Email), IsUnique = true)] public class Employee : IEmployee { [Column("employee_id")] public int Id { get; private set; } [Required] [Column("employee_name")] [MaxLength(50)] public string Name { get; private set; } = string.Empty; [Required] [Column("employee_email")] [MaxLength(40)] public string Email { get; private set; } = string.Empty; [Required] [Column("employee_password")] [MaxLength(32)] public string Password { get; private set; } = string.Empty; public virtual List Sales { get; set; } = new(); private Employee() { } private Employee(IEmployee employee) { Id = employee.Id; Name = employee.Name; Email = employee.Email; Password = employee.Password; } public static Employee? Create(IEmployee employee) { if (employee == null) return null; return new Employee(employee); } public void Update(IEmployee employee) { if(employee == null) return; Name = employee.Name; Email = employee.Email; Password = employee.Password; } public EmployeeView GetView() { return new EmployeeView(this); } } }