SUBD_Aleikin/Restaurant/RestaurantDatabaseImplement/Models/Client.cs

61 lines
1.5 KiB
C#
Raw Permalink Normal View History

using RestaurantContracts.BindingModels;
using RestaurantContracts.ViewModels;
using RestaurantDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RestaurantDatabaseImplement.Models
{
public class Client : IClientModel
{
[Required]
public string FirstName { get; set; } = string.Empty;
[Required]
public string LastName { get; set; } = string.Empty;
[Required]
public string Number { get; set; } = string.Empty;
public int Id { get; set; }
public static Client? Create(ClientBindingModel? model)
{
if (model == null)
{
return null;
}
return new Client()
{
Id = model.Id,
FirstName = model.FirstName,
LastName = model.LastName,
Number = model.Number,
};
}
public void Update(ClientBindingModel? model)
{
if (model == null)
{
return;
}
FirstName = model.FirstName;
LastName = model.LastName;
Number = model.Number;
}
public ClientViewModel GetViewModel => new()
{
Id = Id,
FirstName = FirstName,
LastName = LastName,
Number = Number,
};
}
}