58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
|
using HotelContracts.BindingModels;
|
|||
|
using HotelContracts.ViewModels;
|
|||
|
using HotelDataModels.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 HotelDataBaseImplement.Models
|
|||
|
{
|
|||
|
public class Participant : IParticipantModel
|
|||
|
{
|
|||
|
public int Id { get; private set; }
|
|||
|
|
|||
|
[Required]
|
|||
|
public string FIO { get; set; } = string.Empty;
|
|||
|
|
|||
|
[Required]
|
|||
|
public string Number { get; set; } = string.Empty;
|
|||
|
|
|||
|
public int OrganiserId { get; private set; }
|
|||
|
|
|||
|
public virtual Organiser Organiser { get; set; }
|
|||
|
|
|||
|
[ForeignKey("ParticipantId")]
|
|||
|
public virtual List<MealPlanParticipant> MealPlanParticipants { get; set; } = new();
|
|||
|
|
|||
|
[ForeignKey("ParticipantId")]
|
|||
|
public virtual List<ConferenceParticipant> ConferenceParticipant { get; set; } = new();
|
|||
|
|
|||
|
public static Participant? Create(ParticipantBindingModel model)
|
|||
|
{
|
|||
|
if (model == null) return null;
|
|||
|
return new Participant()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
FIO = model.FIO,
|
|||
|
Number = model.Number,
|
|||
|
OrganiserId = model.OrganiserId,
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public static Participant Create(ParticipantViewModel model)
|
|||
|
{
|
|||
|
return new Participant
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
FIO = model.FIO,
|
|||
|
Number = model.Number,
|
|||
|
OrganiserId = model.OrganiserId,
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
}
|