PIbd-21_Anisin_R.S._CourseW.../TravelAgency/TravelAgencyDatabaseImplement/Models/Guide.cs

55 lines
1.4 KiB
C#
Raw Normal View History

2024-04-28 23:08:12 +04:00
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
};
}
}