75 lines
1.5 KiB
C#
75 lines
1.5 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 BulletinBoardDatabase.Models;
|
|
using BulletinBoardDataModels.Models;
|
|
using BulletinBoardContracts.BindingModels;
|
|
using BulletinBoardContracts.ViewModels;
|
|
|
|
namespace BulletinBoardDatabase.Models
|
|
{
|
|
public class User : IUserModel
|
|
{
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Surname { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string PhoneNumber { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Email { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public int? Id { get; private set; }
|
|
|
|
[ForeignKey("ClientId")]
|
|
List<Announcement> AnnouncementUsers { get; set; } = new();
|
|
|
|
public static User? Create(UserBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new User()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
Surname = model.Surname,
|
|
PhoneNumber = model.PhoneNumber,
|
|
Email = model.Email,
|
|
};
|
|
}
|
|
|
|
public void Update(UserBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
Surname = model.Surname;
|
|
PhoneNumber = model.PhoneNumber;
|
|
Email = model.Email;
|
|
}
|
|
|
|
public UserViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
Surname = Surname,
|
|
PhoneNumber = PhoneNumber,
|
|
Email = Email,
|
|
};
|
|
|
|
public string ObjectId => throw new NotImplementedException();
|
|
}
|
|
}
|