1
This commit is contained in:
parent
acab140234
commit
4d376bc58f
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PizzeriaContracts\PizzeriaContracts.csproj" />
|
||||
<ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
59
Pizzeria/AbstractShopFileImplement/Models/Component.cs
Normal file
59
Pizzeria/AbstractShopFileImplement/Models/Component.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using PizzeriaContracts.BindingModels;
|
||||
using PizzeriaDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AbstractShopFileImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Component()
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public static Component? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Component()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ComponentName = element.Element("ComponentName")!.Value,
|
||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
||||
};
|
||||
}
|
||||
public void Update(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ComponentName = model.ComponentName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public ComponentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost
|
||||
};
|
||||
public XElement GetXElement => new("Component",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ComponentName", ComponentName),
|
||||
new XElement("Cost", Cost.ToString()));
|
||||
}
|
||||
|
||||
}
|
65
Pizzeria/AbstractShopFileImplement/Models/Pizza.cs
Normal file
65
Pizzeria/AbstractShopFileImplement/Models/Pizza.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using PizzeriaContracts.BindingModels;
|
||||
using PizzeriaContracts.ViewModels;
|
||||
using PizzeriaDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AbstractShopFileImplement.Models
|
||||
{
|
||||
public class Pizza : IPizzaModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string PizzaName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, (IComponentModel, int)> PizzaComponents { get; private set; } = new Dictionary<int, (IComponentModel, int)>();
|
||||
public static Pizza? Create(PizzaBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Pizza()
|
||||
{
|
||||
Id = model.Id,
|
||||
PizzaName = model.PizzaName,
|
||||
Price = model.Price,
|
||||
PizzaComponents = model.PizzaComponents
|
||||
};
|
||||
}
|
||||
public static Product? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Product()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ProductName = element.Element("ProductName")!.Value,
|
||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
||||
Components =
|
||||
element.Element("ProductComponents")!.Elements("ProductComponent")
|
||||
.ToDictionary(x =>
|
||||
Convert.ToInt32(x.Element("Key")?.Value), x =>
|
||||
Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(PizzaBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PizzaName = model.PizzaName;
|
||||
Price = model.Price;
|
||||
PizzaComponents = model.PizzaComponents;
|
||||
}
|
||||
public PizzaViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PizzaName = PizzaName,
|
||||
Price = Price,
|
||||
PizzaComponents = PizzaComponents
|
||||
};
|
||||
}
|
||||
}
|
@ -3,15 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34616.47
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pizzeria", "Pizzeria\Pizzeria.csproj", "{FBB3868C-DAC0-4481-9E44-16F7AAE00141}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pizzeria", "Pizzeria\Pizzeria.csproj", "{FBB3868C-DAC0-4481-9E44-16F7AAE00141}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaDataModels", "PizzeriaDataModels\PizzeriaDataModels.csproj", "{CD0B496B-7660-4744-9F6E-2ACF483F0299}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaDataModels", "PizzeriaDataModels\PizzeriaDataModels.csproj", "{CD0B496B-7660-4744-9F6E-2ACF483F0299}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaContracts", "PizzeriaContracts\PizzeriaContracts.csproj", "{F039417A-21F0-4947-9623-C89A755AB8DD}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaContracts", "PizzeriaContracts\PizzeriaContracts.csproj", "{F039417A-21F0-4947-9623-C89A755AB8DD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaListImplement", "PizzeriaListImplement\PizzeriaListImplement.csproj", "{6640B0DE-53D5-4DE7-909A-C8111D5347EA}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaListImplement", "PizzeriaListImplement\PizzeriaListImplement.csproj", "{6640B0DE-53D5-4DE7-909A-C8111D5347EA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaBusinessLogic", "PizzeriaBusinessLogic\PizzeriaBusinessLogic.csproj", "{16EC5652-8348-4520-9736-1889B2749416}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaBusinessLogic", "PizzeriaBusinessLogic\PizzeriaBusinessLogic.csproj", "{16EC5652-8348-4520-9736-1889B2749416}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractShopFileImplement", "AbstractShopFileImplement\AbstractShopFileImplement.csproj", "{87ACB324-2C2F-48B1-A945-0F348CCA8F69}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -39,6 +41,10 @@ Global
|
||||
{16EC5652-8348-4520-9736-1889B2749416}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{16EC5652-8348-4520-9736-1889B2749416}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{16EC5652-8348-4520-9736-1889B2749416}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{87ACB324-2C2F-48B1-A945-0F348CCA8F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{87ACB324-2C2F-48B1-A945-0F348CCA8F69}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{87ACB324-2C2F-48B1-A945-0F348CCA8F69}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{87ACB324-2C2F-48B1-A945-0F348CCA8F69}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -9,11 +9,7 @@ namespace PizzeriaListImplement.Models
|
||||
public int Id { get; private set; }
|
||||
public string PizzaName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, (IComponentModel, int)> PizzaComponents
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = new Dictionary<int, (IComponentModel, int)>();
|
||||
public Dictionary<int, (IComponentModel, int)> PizzaComponents {get;private set;} = new Dictionary<int, (IComponentModel, int)>();
|
||||
public static Pizza? Create(PizzaBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
|
Loading…
Reference in New Issue
Block a user