PIbd-22-Stroev-V.M.-Plumbin.../PlumbingRepair/PlumbingRepairListImplement/Models/Store.cs

61 lines
1.7 KiB
C#
Raw Normal View History

2024-05-05 00:19:00 +04:00
using PlumbingRepairContracts.BindingModels;
using PlumbingRepairContracts.ViewModels;
using PlumbingRepairDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PlumbingRepairListImplement.Models
{
public class Store : IStoreModel
{
public string StoreName { get; private set; } = string.Empty;
public string StoreAdress { get; private set; } = string.Empty;
public DateTime OpeningDate { get; private set; }
public Dictionary<int, (IWorkModel, int)> Works { get; private set; } = new();
public int Id { get; private set; }
public static Store? Create(StoreBindingModel? model)
{
if (model == null)
{
return null;
}
return new Store()
{
Id = model.Id,
StoreName = model.StoreName,
StoreAdress = model.StoreAdress,
OpeningDate = model.OpeningDate,
Works = new()
};
}
public void Update(StoreBindingModel? model)
{
if (model == null)
{
return;
}
StoreName = model.StoreName;
StoreAdress = model.StoreAdress;
OpeningDate = model.OpeningDate;
Works = model.Works;
}
public StoreViewModel GetViewModel => new()
{
Id = Id,
StoreName = StoreName,
StoreAdress = StoreAdress,
OpeningDate = OpeningDate,
Works = Works
};
}
}