CourseWork_EventVisitor/EventVisitor/EventVisitorDatabase/Entities/OrganizerEntity.cs

93 lines
2.7 KiB
C#
Raw Normal View History

2024-11-03 01:20:30 +04:00
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;
2024-11-03 10:18:08 +04:00
using System.ComponentModel.DataAnnotations;
2024-11-03 01:20:30 +04:00
namespace EventVisitorDatabase.Entities
{
public class OrganizerEntity
{
public int Id { get; set; }
2024-11-03 10:18:08 +04:00
[Required]
2024-11-03 01:20:30 +04:00
public string Surname { get; set; } = string.Empty;
2024-11-03 10:18:08 +04:00
[Required]
2024-11-03 01:20:30 +04:00
public string Name { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string OrganizationName { get; set; } = string.Empty;
2024-11-03 10:18:08 +04:00
[Required]
public string Email { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[Required]
2024-11-03 01:20:30 +04:00
public string Phone { get; set; } = string.Empty;
2024-11-03 01:20:30 +04:00
public static OrganizerEntity? Create(OrganizerBindingModel model)
{
if (model == null)
{
return null;
}
return new OrganizerEntity()
{
Id = model.Id,
2024-11-03 01:20:30 +04:00
Name = model.Name,
Phone = model.Phone,
Surname = model.Surname,
LastName = model.LastName,
OrganizationName = model.OrganizationName,
Email = model.Email,
Password = model.Password
2024-11-03 01:20:30 +04:00
};
}
public static OrganizerEntity Create(OrganizerViewModel model)
{
return new OrganizerEntity()
{
Id = model.Id,
Name = model.Name,
Phone = model.Phone,
Surname = model.Surname,
LastName = model.LastName,
OrganizationName = model.OrganizationName,
Email = model.Email,
Password= model.Password
2024-11-03 01:20:30 +04:00
};
}
public void Update(OrganizerBindingModel model)
{
Name = model.Name;
Phone = model.Phone;
Surname = model.Surname;
LastName = model.LastName;
OrganizationName = model.OrganizationName;
Password = model.Password;
2024-11-03 01:20:30 +04:00
}
public OrganizerViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Phone = Phone,
Surname = Surname,
LastName = LastName,
OrganizationName = OrganizationName,
Email = Email,
Password = Password
2024-11-03 01:20:30 +04:00
};
}
}