58 lines
1.4 KiB
C#
58 lines
1.4 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; } = string.Empty;
|
|
public string Adress { get; private set; } = string.Empty;
|
|
public DateTime OpeningDate { get; private set; }
|
|
public Dictionary<int, (IEngineModel, int)> ShopEngines { get; private set; } = new();
|
|
public int EngineMaxCount { get; private set; }
|
|
|
|
public static Shop? Create(ShopBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Shop()
|
|
{
|
|
Id = model.Id,
|
|
ShopName = model.ShopName,
|
|
Adress = model.Adress,
|
|
OpeningDate = model.OpeningDate,
|
|
EngineMaxCount = model.EngineMaxCount,
|
|
};
|
|
}
|
|
public void Update(ShopBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
ShopName = model.ShopName;
|
|
Adress = model.Adress;
|
|
OpeningDate = model.OpeningDate;
|
|
EngineMaxCount = model.EngineMaxCount;
|
|
}
|
|
public ShopViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ShopName = ShopName,
|
|
Adress = Adress,
|
|
OpeningDate = OpeningDate,
|
|
ShopEngines = ShopEngines,
|
|
EngineMaxCount = EngineMaxCount,
|
|
};
|
|
}
|
|
}
|