PIbd-21_Pyatakov_KM_Markov_.../UniversityDataBaseImplemet/Models/User.cs
2023-04-07 19:22:59 +04:00

47 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
namespace UniversityDataBaseImplemet.Models
{
public class User
{
public int Id { get; private set; }
[Required]
public string Login { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[Required]
public int RoleId { get; set; }
public static User Create(UserBindingModel model)
{
return new User()
{
Id = model.Id,
Login = model.Login,
Password = model.Password,
RoleId = model.RoleId
};
}
public void Update(UserBindingModel model)
{
Password = model.Password;
RoleId = model.RoleId;
}
public UserViewModel GetViewModel => new()
{
Id = Id,
Login = Login,
Password = Password,
RoleId = RoleId
};
}
}