82 lines
2.7 KiB
C#
82 lines
2.7 KiB
C#
using BankContracts.BindingModels;
|
|
using BankContracts.ViewModels;
|
|
using BankDataModels.Models;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace BankDataBaseImplement.Models
|
|
{
|
|
public class Clerc : IClercModel
|
|
{
|
|
[Required]
|
|
public string OrganiserFIO { get; set; } = string.Empty;
|
|
[Required]
|
|
public string OrganiserPassword { get; set; } = string.Empty;
|
|
[Required]
|
|
public string OrganiserLogin { get; set; } = string.Empty;
|
|
[Required]
|
|
public string OrganiserEmail { get; set; } = string.Empty;
|
|
[Required]
|
|
public string OrganiserNumber { get; set; } = string.Empty;
|
|
|
|
public int Id { get; private set; }
|
|
|
|
[ForeignKey("OrganiserId")]
|
|
public virtual List<Conference> Conferences { get; set; } = new();
|
|
[ForeignKey("OrganiserId")]
|
|
public virtual List<MealPlan> MealPlans { get; set; } = new();
|
|
[ForeignKey("OrganiserId")]
|
|
public virtual List<Member> Members { get; set; } = new();
|
|
|
|
public static Clerc? Create(ClercBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Clerc()
|
|
{
|
|
Id = model.Id,
|
|
OrganiserFIO = model.OrganiserFIO,
|
|
OrganiserEmail = model.OrganiserEmail,
|
|
OrganiserPassword = model.OrganiserPassword,
|
|
OrganiserLogin = model.OrganiserLogin,
|
|
OrganiserNumber = model.OrganiserNumber
|
|
};
|
|
}
|
|
public static Clerc Create(ClercViewModel model)
|
|
{
|
|
return new Clerc
|
|
{
|
|
Id = model.Id,
|
|
OrganiserFIO = model.OrganiserFIO,
|
|
OrganiserEmail = model.OrganiserEmail,
|
|
OrganiserPassword = model.OrganiserPassword,
|
|
OrganiserLogin= model.OrganiserLogin,
|
|
OrganiserNumber= model.OrganiserNumber
|
|
};
|
|
}
|
|
public void Update(ClercBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
OrganiserFIO = model.OrganiserFIO;
|
|
OrganiserEmail = model.OrganiserEmail;
|
|
OrganiserPassword = model.OrganiserPassword;
|
|
OrganiserLogin = model.OrganiserLogin;
|
|
OrganiserNumber = model.OrganiserNumber;
|
|
}
|
|
public ClercViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
OrganiserFIO = OrganiserFIO,
|
|
OrganiserEmail = OrganiserEmail,
|
|
OrganiserPassword = OrganiserPassword,
|
|
OrganiserNumber = OrganiserNumber,
|
|
OrganiserLogin = OrganiserLogin
|
|
};
|
|
}
|
|
}
|