74 lines
1.8 KiB
C#
74 lines
1.8 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 ParticipantFIO { 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> ConferenceParticipants { get; set; } = new();
|
|
|
|
public static Participant? Create(ParticipantBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
return new Participant()
|
|
{
|
|
Id = model.Id,
|
|
ParticipantFIO = model.ParticipantFIO,
|
|
Number = model.Number,
|
|
OrganiserId = model.OrganiserId,
|
|
};
|
|
}
|
|
|
|
public static Participant Create(ParticipantViewModel model)
|
|
{
|
|
return new Participant
|
|
{
|
|
Id = model.Id,
|
|
ParticipantFIO = model.ParticipantFIO,
|
|
Number = model.Number,
|
|
OrganiserId = model.OrganiserId,
|
|
};
|
|
}
|
|
|
|
public void Update(ParticipantBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
ParticipantFIO = model.ParticipantFIO;
|
|
Number = model.Number;
|
|
OrganiserId = model.OrganiserId;
|
|
}
|
|
|
|
public ParticipantViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ParticipantFIO = ParticipantFIO,
|
|
Number = Number,
|
|
OrganiserId = OrganiserId,
|
|
};
|
|
}
|
|
}
|