71 lines
1.5 KiB
C#
71 lines
1.5 KiB
C#
using ComputerShopContracts.BindingModels;
|
|
using ComputerShopContracts.ViewModels;
|
|
using ComputerShopDataModels.Enums;
|
|
using ComputerShopDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ComputerShopDatabaseImplement.Models
|
|
{
|
|
public class User : IUserModel
|
|
{
|
|
public int Id { get; private set; }
|
|
|
|
[Required]
|
|
public string Fio { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string PhoneNumber { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Login { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Email { get; set; } = string.Empty;
|
|
|
|
|
|
public static User Create(UserBindingModel model)
|
|
{
|
|
return new User
|
|
{
|
|
Id = model.Id,
|
|
Fio = model.Fio,
|
|
PhoneNumber = model.PhoneNumber,
|
|
Login = model.Login,
|
|
Password = model.Password,
|
|
Email = model.Email,
|
|
};
|
|
}
|
|
|
|
public void Update(UserBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Fio = model.Fio;
|
|
PhoneNumber = model.PhoneNumber;
|
|
Login = model.Login;
|
|
Password = model.Password;
|
|
Email = model.Email;
|
|
}
|
|
|
|
public UserViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Fio = Fio,
|
|
PhoneNumber = PhoneNumber,
|
|
Login = Login,
|
|
Password = Password,
|
|
Email = Email,
|
|
};
|
|
}
|
|
}
|