using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Net.NetworkInformation; using System.Net; using System.Text; using System.Threading.Tasks; using static System.Runtime.InteropServices.JavaScript.JSType; using EventVisitorLogic.BindingModels; using EventVisitorLogic.ViewModels; using System.ComponentModel.DataAnnotations; namespace EventVisitorDatabase.Entities { public class OrganizerEntity { public int Id { get; set; } [Required] public string Surname { get; set; } = string.Empty; [Required] public string Name { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; public string OrganizationName { get; set; } = string.Empty; [Required] public string Role { get; set; } = string.Empty; [Required] public string Email { get; set; } = string.Empty; [Required] public string Password { get; set; } = string.Empty; [Required] public string Phone { get; set; } = string.Empty; public static OrganizerEntity? Create(OrganizerBindingModel model) { if (model == null) { return null; } return new OrganizerEntity() { Id = model.Id, Name = model.Name, Phone = model.Phone, Role = model.Role, Surname = model.Surname, LastName = model.LastName, OrganizationName = model.OrganizationName, Email = model.Email, Password = model.Password }; } public static OrganizerEntity Create(OrganizerViewModel model) { return new OrganizerEntity() { Id = model.Id, Name = model.Name, Phone = model.Phone, Role = model.Role, Surname = model.Surname, LastName = model.LastName, OrganizationName = model.OrganizationName, Email = model.Email, Password= model.Password }; } public void Update(OrganizerBindingModel model) { Name = model.Name; Phone = model.Phone; Role = model.Role; Surname = model.Surname; LastName = model.LastName; OrganizationName = model.OrganizationName; Password = model.Password; } public OrganizerViewModel GetViewModel => new() { Id = Id, Name = Name, Phone = Phone, Role = Role, Surname = Surname, LastName = LastName, OrganizationName = OrganizationName, Email = Email, Password = Password }; } }