2023-04-02 16:32:10 +04:00
|
|
|
|
using HotelContracts.BindingModels;
|
|
|
|
|
using HotelContracts.ViewModels;
|
|
|
|
|
using HotelDataModels.Models;
|
2023-04-02 16:19:39 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2023-04-02 14:32:57 +04:00
|
|
|
|
|
|
|
|
|
namespace HotelDataBaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Member : IMemberModel
|
|
|
|
|
{
|
2023-04-02 16:19:39 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string MemberFIO { get; set; } = string.Empty;
|
2023-04-02 14:32:57 +04:00
|
|
|
|
|
2023-04-02 16:19:39 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string Citizenship { get; set; } = string.Empty;
|
2023-04-02 14:32:57 +04:00
|
|
|
|
|
2023-04-02 16:19:39 +04:00
|
|
|
|
public int OrganiserId { get; private set; }
|
2023-04-02 14:32:57 +04:00
|
|
|
|
|
2023-04-02 16:19:39 +04:00
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
|
|
|
|
|
public virtual Organiser Organiser { get; set; }
|
|
|
|
|
|
|
|
|
|
[ForeignKey("MemberId")]
|
|
|
|
|
public virtual List<MealPlanMember> MealPlanMember { get; set; }
|
|
|
|
|
|
|
|
|
|
[ForeignKey("MemberId")]
|
|
|
|
|
public virtual List<ConferenceMember> ConferenceMember { get; set; }
|
2023-04-02 16:32:10 +04:00
|
|
|
|
public static Member? Create(MemberBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Member()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
MemberFIO = model.MemberFIO,
|
2023-05-14 17:51:51 +04:00
|
|
|
|
Citizenship = model.Citizenship,
|
|
|
|
|
OrganiserId = model.OrganiserId,
|
2023-04-02 16:32:10 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public static Member Create(MemberViewModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Member
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
MemberFIO = model.MemberFIO,
|
2023-05-14 17:51:51 +04:00
|
|
|
|
Citizenship = model.Citizenship,
|
|
|
|
|
OrganiserId=model.OrganiserId,
|
2023-04-02 16:32:10 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(MemberBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MemberFIO = model.MemberFIO;
|
|
|
|
|
Citizenship = model.Citizenship;
|
2023-05-14 17:51:51 +04:00
|
|
|
|
OrganiserId = model.OrganiserId;
|
2023-04-02 16:32:10 +04:00
|
|
|
|
}
|
|
|
|
|
public MemberViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
MemberFIO = MemberFIO,
|
2023-05-14 17:51:51 +04:00
|
|
|
|
Citizenship = Citizenship,
|
|
|
|
|
OrganiserId=OrganiserId
|
2023-04-02 16:32:10 +04:00
|
|
|
|
};
|
2023-04-02 14:32:57 +04:00
|
|
|
|
}
|
|
|
|
|
}
|