55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using TravelAgencyContracts.BindingModels;
|
|||
|
using TravelAgencyContracts.ViewModels;
|
|||
|
using TravelAgencyDataModels.Models;
|
|||
|
|
|||
|
namespace TravelAgencyDatabaseImplement.Models
|
|||
|
{
|
|||
|
public class Guide : IGuideModel
|
|||
|
{
|
|||
|
public int Id { get; set; }
|
|||
|
|
|||
|
[Required]
|
|||
|
public string GuideFIO { get; set; } = string.Empty;
|
|||
|
|
|||
|
[Required]
|
|||
|
public string Email { get; set; } = string.Empty;
|
|||
|
|
|||
|
[Required]
|
|||
|
public string PhoneNumber { get; set; } = string.Empty;
|
|||
|
|
|||
|
public static Guide? Create(GuideBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Guide()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
GuideFIO = model.GuideFIO,
|
|||
|
Email = model.Email,
|
|||
|
PhoneNumber = model.PhoneNumber
|
|||
|
};
|
|||
|
}
|
|||
|
public void Update(GuideBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
GuideFIO = model.GuideFIO;
|
|||
|
Email = model.Email;
|
|||
|
PhoneNumber = model.PhoneNumber;
|
|||
|
}
|
|||
|
|
|||
|
public GuideViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
GuideFIO = GuideFIO,
|
|||
|
Email = Email,
|
|||
|
PhoneNumber = PhoneNumber
|
|||
|
};
|
|||
|
}
|
|||
|
}
|