91 lines
2.7 KiB
C#
91 lines
2.7 KiB
C#
|
using ServiceStationContracts.BindingModels;
|
|||
|
using ServiceStationContracts.ViewModels;
|
|||
|
using ServiceStationDataModels;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace ServiceStationsDataBaseImplement.Models
|
|||
|
{
|
|||
|
public class Client : IClientModel
|
|||
|
{
|
|||
|
[Required]
|
|||
|
public string FirstName { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string LastName { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string Email { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string Password { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string PhoneNumber { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string Login { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public int Point { get; set; }
|
|||
|
public int Id { get; set; }
|
|||
|
public static Client? Create(ClientBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Client()
|
|||
|
{
|
|||
|
FirstName = model.FirstName,
|
|||
|
LastName = model.LastName,
|
|||
|
Email = model.Email,
|
|||
|
Password = model.Password,
|
|||
|
PhoneNumber = model.PhoneNumber,
|
|||
|
Login = model.Login,
|
|||
|
Point = model.Point,
|
|||
|
Id = model.Id
|
|||
|
|
|||
|
};
|
|||
|
}
|
|||
|
public static Client? Create(ClientViewModel model)
|
|||
|
{
|
|||
|
return new Client
|
|||
|
{
|
|||
|
FirstName = model.FirstName,
|
|||
|
LastName = model.LastName,
|
|||
|
Email = model.Email,
|
|||
|
Password = model.Password,
|
|||
|
PhoneNumber = model.PhoneNumber,
|
|||
|
Login = model.Login,
|
|||
|
Point = model.Point,
|
|||
|
Id = model.Id
|
|||
|
};
|
|||
|
}
|
|||
|
public void Update(ClientBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
FirstName = model.FirstName;
|
|||
|
LastName = model.LastName;
|
|||
|
Email = model.Email;
|
|||
|
Password = model.Password;
|
|||
|
PhoneNumber = model.PhoneNumber;
|
|||
|
Login = model.Login;
|
|||
|
Point = model.Point;
|
|||
|
|
|||
|
}
|
|||
|
public ClientViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
FirstName = FirstName,
|
|||
|
LastName = LastName,
|
|||
|
Email = Email,
|
|||
|
Password = Password,
|
|||
|
PhoneNumber = PhoneNumber,
|
|||
|
Login = Login,
|
|||
|
Point = Point,
|
|||
|
Id = Id
|
|||
|
};
|
|||
|
}
|
|||
|
}
|