40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using DinerContracts.BindingModels;
|
|
using DinerContracts.ViewModels;
|
|
using DinerDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DinerListImplement.Models
|
|
{
|
|
internal class Food : IFoodModel
|
|
{
|
|
public string ComponentName { get; private set; } = string.Empty;
|
|
|
|
public double Price { get; set; }
|
|
|
|
public int ID { get; private set; }
|
|
|
|
public static Food? Create(FoodBindingModel? model) {
|
|
if (model == null) return null;
|
|
return new Food() {
|
|
ID = model.ID,
|
|
ComponentName = model.ComponentName,
|
|
Price = model.Price,
|
|
};
|
|
}
|
|
public void Update(FoodBindingModel? model) {
|
|
if (model == null) return;
|
|
ComponentName = model.ComponentName;
|
|
Price = model.Price;
|
|
}
|
|
public FoodViewModel GetViewModel => new(){
|
|
ID = ID,
|
|
ComponentName = ComponentName,
|
|
Price = Price,
|
|
};
|
|
}
|
|
}
|