using Contracts.BindingModels; using Contracts.ViewModels; using DataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DatabaseImplement.Models { /// /// Сущность "Счет" /// public class Order : IOrderModel { /// /// Идентификатор /// public int Id { get; private set; } /// /// ФИО водителя /// [Required] public string WaiterFullName { get; private set; } = string.Empty; /// /// Информация по счету /// [Required] public string Info { get; private set; } = string.Empty; /// /// Тип заказа /// [Required] public string Type { get; private set; } = string.Empty; /// /// Сумма заказа /// public double? Sum { get; private set; } /// /// Создать модель /// /// /// public static Order? Create(OrderBindingModel model) { if (model == null) { return null; } return new Order { Id = model.Id, WaiterFullName = model.WaiterFullName, Info = model.Info, Type = model.Type, Sum = model.Sum, }; } /// /// Изменить модель /// /// public void Update(OrderBindingModel model) { if (model == null) { return; } WaiterFullName = model.WaiterFullName; Info = model.Info; Type = model.Type; Sum = model.Sum; } /// /// Получить модель отображения /// public OrderViewModel GetViewModel => new() { Id = Id, WaiterFullName = WaiterFullName, Info = Info, Type = Type, Sum = Sum.ToString(), }; } }