55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
|
using MotorPlantContracts.BindingModels;
|
|||
|
using MotorPlantContracts.ViewModels;
|
|||
|
using MotorPlantDataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace MotorPlantListImplement.Models
|
|||
|
{
|
|||
|
public class Shop : IShopModel
|
|||
|
{
|
|||
|
public int Id { get; private set; }
|
|||
|
public string ShopName { get; private set; }
|
|||
|
public string Adress { get; private set; }
|
|||
|
public DateTime DateOpen { get; private set; }
|
|||
|
public Dictionary<int, (IEngineModel, int)> ShopEngines { get; private set; } = new();
|
|||
|
public static Shop? Create(ShopBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Shop()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
ShopName = model.ShopName,
|
|||
|
Adress = model.Adress,
|
|||
|
DateOpen = model.DateOpen,
|
|||
|
ShopEngines = new()
|
|||
|
};
|
|||
|
}
|
|||
|
public void Update(ShopBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
ShopName = model.ShopName;
|
|||
|
Adress = model.Adress;
|
|||
|
DateOpen = model.DateOpen;
|
|||
|
ShopEngines = model.ShopEngines;
|
|||
|
}
|
|||
|
public ShopViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
ShopName = ShopName,
|
|||
|
Adress = Adress,
|
|||
|
DateOpen = DateOpen,
|
|||
|
ShopEngines = ShopEngines
|
|||
|
};
|
|||
|
}
|
|||
|
}
|