59 lines
1.6 KiB
C#
Raw Normal View History

2023-05-06 16:30:44 +04:00
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.ViewModels;
using BeautySaloonDataModels;
using MongoDB.Bson.Serialization.Attributes;
namespace BeautySaloonNoSQLDatabaseImplement
{
public class Client : IClientModel
{
[BsonId]
[BsonElement("_id"), BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
private string IdMongo { get; set; } = string.Empty;
[BsonElement("id")]
public int Id { get; set; }
[BsonElement("name")]
public string Name { get; set; } = string.Empty;
[BsonElement("surname")]
public string Surname { get; set; } = string.Empty;
[BsonElement("patronymic")]
public string Patronymic { get; set; } = string.Empty;
[BsonElement("phone")]
public string Phone { get; set; } = string.Empty;
public static Client Create(ClientBindingModel model)
{
return new Client()
{
Id = model.Id,
Name = model.Name,
Surname = model.Surname,
Patronymic = model.Patronymic,
Phone = model.Phone
};
}
public void Update(ClientBindingModel model)
{
Name = model.Name;
Surname = model.Surname;
Patronymic = model.Patronymic;
Phone = model.Phone;
}
public ClientViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Surname = Surname,
Patronymic = Patronymic,
Phone = Phone
};
}
}