2024-05-01 21:35:57 +04:00
|
|
|
|
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
|
|
|
|
|
{
|
2024-05-05 21:43:24 +04:00
|
|
|
|
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();
|
2024-06-03 01:11:08 +04:00
|
|
|
|
public int MaxCount { get; private set; }
|
2024-05-05 21:43:24 +04:00
|
|
|
|
|
|
|
|
|
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,
|
2024-06-03 01:11:08 +04:00
|
|
|
|
MaxCount = model.MaxCount,
|
2024-05-05 21:43:24 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(ShopBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ShopName = model.ShopName;
|
|
|
|
|
Adress = model.Adress;
|
|
|
|
|
OpeningDate = model.OpeningDate;
|
2024-06-03 01:11:08 +04:00
|
|
|
|
MaxCount = model.MaxCount;
|
2024-05-05 21:43:24 +04:00
|
|
|
|
}
|
|
|
|
|
public ShopViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
ShopName = ShopName,
|
|
|
|
|
Adress = Adress,
|
|
|
|
|
OpeningDate = OpeningDate,
|
|
|
|
|
ShopEngines = ShopEngines,
|
2024-06-03 01:11:08 +04:00
|
|
|
|
MaxCount = MaxCount,
|
2024-05-05 21:43:24 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
2024-05-01 21:35:57 +04:00
|
|
|
|
}
|