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 Menu : IMenuModel { [BsonId] [BsonElement("_id")] public int Id { get; set; } [BsonRequired] public string FoodName { get; set; } = string.Empty; [BsonRequired] public string Description { get; set; } = string.Empty; [BsonRequired] public double Price { get; set; } public static Menu? Create(MenuBindingModel model) { if (model == null) return null; return new Menu() { Id = model.Id, FoodName = model.FoodName, Description = model.Description, Price = model.Price, }; } public void Update(MenuBindingModel model) { if (model == null) return; Id = model.Id; FoodName = model.FoodName; Description = model.Description; Price = model.Price; } public MenuViewModel GetViewModel => new() { Id = Id, FoodName = FoodName, Description = Description, Price = Price, }; } }