53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using MongoDB.Bson.Serialization.Attributes;
|
|
using MongoDB.Bson;
|
|
using SushiBarDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using SushiBarContracts.BindingModels;
|
|
using SushiBarContracts.ViewModels;
|
|
|
|
namespace SushiBarMongoDB.Models
|
|
{
|
|
public class Place : IPlaceModel
|
|
{
|
|
[BsonId]
|
|
[BsonElement("_id")]
|
|
public int Id { get; set; }
|
|
|
|
[BsonRequired]
|
|
public int PlaceNumber { get; set; }
|
|
|
|
[BsonRequired]
|
|
public int CountPlaces { get; set; }
|
|
|
|
public static Place? Create(PlaceBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
return new Place()
|
|
{
|
|
Id = model.Id,
|
|
PlaceNumber = model.PlaceNumber,
|
|
CountPlaces = model.CountPlaces,
|
|
};
|
|
}
|
|
|
|
public void Update(PlaceBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
Id = model.Id;
|
|
PlaceNumber = model.PlaceNumber;
|
|
CountPlaces = model.CountPlaces;
|
|
}
|
|
|
|
public PlaceViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
PlaceNumber = PlaceNumber,
|
|
CountPlaces = CountPlaces,
|
|
};
|
|
}
|
|
}
|