94 lines
2.8 KiB
C#
94 lines
2.8 KiB
C#
using BankContracts.BindingModels;
|
|
using BankContracts.ViewModels;
|
|
using BankDataModels.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 BankDataBaseImplement.Models
|
|
{
|
|
public class Client : IClientModel
|
|
{
|
|
public int Id { get; private set; }
|
|
|
|
[Required]
|
|
public string ClientFIO { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string ClientEmail { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string ClientPassword { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string ClientLogin { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string ClientNumber { get; set; } = string.Empty;
|
|
|
|
|
|
[ForeignKey("HeadwaiterId")]
|
|
public virtual List<Room> Rooms { get; set; } = new();
|
|
|
|
[ForeignKey("HeadwaiterId")]
|
|
public virtual List<Credit> Dinners { get; set; } = new();
|
|
|
|
[ForeignKey("HeadwaiterId")]
|
|
public virtual List<ConferenceBooking> ConferenceBookings { get; set; } = new();
|
|
public static Client? Create(ClientBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Client()
|
|
{
|
|
Id = model.Id,
|
|
ClientFIO = model.ClientFIO,
|
|
ClientEmail = model.ClientEmail,
|
|
ClientPassword = model.ClientPassword,
|
|
ClientLogin = model.ClientLogin,
|
|
ClientNumber = model.ClientNumber
|
|
};
|
|
}
|
|
public static Client Create(ClientViewModel model)
|
|
{
|
|
return new Client
|
|
{
|
|
Id = model.Id,
|
|
ClientFIO = model.ClientFIO,
|
|
ClientEmail = model.ClientEmail,
|
|
ClientPassword = model.ClientPassword,
|
|
ClientLogin = model.ClientLogin,
|
|
ClientNumber = model.ClientNumber
|
|
};
|
|
}
|
|
public void Update(ClientBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
ClientFIO = model.ClientFIO;
|
|
ClientEmail = model.ClientEmail;
|
|
ClientPassword = model.ClientPassword;
|
|
ClientLogin = model.ClientLogin;
|
|
ClientNumber = model.ClientNumber;
|
|
}
|
|
public ClientViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ClientFIO = ClientFIO,
|
|
ClientEmail = ClientEmail,
|
|
ClientPassword = ClientPassword,
|
|
ClientLogin = ClientLogin,
|
|
ClientNumber = ClientNumber
|
|
};
|
|
|
|
}
|
|
}
|