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 Cook : ICookModel { [BsonId] [BsonElement("_id")] public int Id { get; set; } [BsonRequired] public string CookName { get; set; } = string.Empty; [BsonRequired] public string CookSurname { get; set; } = string.Empty; [BsonRequired] public int Experience { get; set; } [BsonRequired] public string PhoneNumber { get; set; } = string.Empty; [BsonRequired] public string Passport { get; set; } = string.Empty; public static Cook? Create(CookBindingModel model) { if (model == null) return null; return new Cook() { Id = model.Id, CookName = model.CookName, CookSurname = model.CookSurname, Experience = model.Experience, PhoneNumber = model.PhoneNumber, Passport = model.Passport, }; } public void Update(CookBindingModel model) { if (model == null) return; Id = model.Id; CookName = model.CookName; CookSurname = model.CookSurname; Experience = model.Experience; PhoneNumber = model.PhoneNumber; Passport = model.Passport; } public CookViewModel GetViewModel => new() { Id = Id, CookName = CookName, CookSurname = CookSurname, Experience = Experience, PhoneNumber = PhoneNumber, Passport = Passport }; } }