46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using BeautySaloonContracts.BindingModels;
|
|
using BeautySaloonContracts.ViewModels;
|
|
using BeautySaloonDataModels;
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
|
|
namespace BeautySaloonNoSQLDatabaseImplement
|
|
{
|
|
public class Service : IServiceModel
|
|
{
|
|
[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("price"), BsonRepresentation(MongoDB.Bson.BsonType.Double)]
|
|
public decimal Price { get; set; }
|
|
|
|
public static Service Create(ServiceBindingModel model)
|
|
{
|
|
return new Service()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
Price = model.Price
|
|
};
|
|
}
|
|
public void Update(ServiceBindingModel model)
|
|
{
|
|
Name = model.Name;
|
|
Price = model.Price;
|
|
}
|
|
|
|
public ServiceViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
Price = Price
|
|
};
|
|
}
|
|
}
|