57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using ConstructionFirmDataModels.Models;
|
|
using Subd_4.BindingModels;
|
|
using Subd_4.ViewModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace ConstructionFirmDatabaseImplement.Models
|
|
{
|
|
public class Client : IClientModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public string Organization { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string ContractPerson { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Phone { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Email { get; set; } = string.Empty;
|
|
|
|
public static Client? Create(ClientBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
|
|
return new Client()
|
|
{
|
|
Id = model.Id,
|
|
Organization = model.Organization,
|
|
ContractPerson = model.ContractPerson,
|
|
Phone = model.Phone,
|
|
Email = model.Email
|
|
};
|
|
}
|
|
|
|
public void Update(ClientBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
Organization = model.Organization;
|
|
ContractPerson = model.ContractPerson;
|
|
Phone = model.Phone;
|
|
Email = model.Email;
|
|
}
|
|
|
|
public ClientViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Organization = Organization,
|
|
ContractPerson = ContractPerson,
|
|
Phone = Phone,
|
|
Email = Email
|
|
};
|
|
}
|
|
}
|