56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using PlumbingRepairContracts.BindingModels;
|
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
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 Work : IWorkModel
|
|
{
|
|
public int Id { get; private set; }
|
|
public string WorkName { get; private set; } = string.Empty;
|
|
public double Price { get; private set; }
|
|
public Dictionary<int, (IComponentModel, int)> WorkComponents
|
|
{
|
|
get;
|
|
private set;
|
|
} = new Dictionary<int, (IComponentModel, int)>();
|
|
public static Work? Create(WorkBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Work()
|
|
{
|
|
Id = model.Id,
|
|
WorkName = model.WorkName,
|
|
Price = model.Price,
|
|
WorkComponents = model.WorkComponents
|
|
};
|
|
}
|
|
public void Update(WorkBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
WorkName = model.WorkName;
|
|
Price = model.Price;
|
|
WorkComponents = model.WorkComponents;
|
|
}
|
|
public WorkViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
WorkName = WorkName,
|
|
Price = Price,
|
|
WorkComponents = WorkComponents
|
|
};
|
|
}
|
|
}
|