using SushiBarContracts.BindingModels; using SushiBarContracts.ViewModels; using SushiBarDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SushiBarDatabaseImplement.Models { public class Place : IPlaceModel { [Required] public int Id { get; set; } [Required] public int PlaceNumber { get; set; } [Required] 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; PlaceNumber = model.PlaceNumber; CountPlaces = model.CountPlaces; } public PlaceViewModel GetViewModel => new() { Id = Id, PlaceNumber = PlaceNumber, CountPlaces = CountPlaces }; } }