Delete .idea
This commit is contained in:
parent
a44b0f052d
commit
48e89f3b9f
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RiderProjectSettingsUpdater">
|
||||
<option name="vcsConfiguration" value="2" />
|
||||
</component>
|
||||
</project>
|
6
SushiBar/.idea/.idea.SushiBar/.idea/vcs.xml
generated
6
SushiBar/.idea/.idea.SushiBar/.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
104
SushiBar/SushiBarFileImplement/Models/Store.cs
Normal file
104
SushiBar/SushiBarFileImplement/Models/Store.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System.Xml.Linq;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
public class Store : IStoreModel
|
||||
{
|
||||
public int Id { get; private init; }
|
||||
public string StoreName { get; private set; } = string.Empty;
|
||||
public string StoreAddress { get; private set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; private set; }
|
||||
public int maxSushi { get; private set; }
|
||||
|
||||
private Dictionary<int, int> _sushi = new();
|
||||
|
||||
public Dictionary<int, (ISushiModel, int)> Sushis
|
||||
{
|
||||
get
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
return _sushi.ToDictionary(i => i.Key,
|
||||
i => (source.Sushis.FirstOrDefault(z => z.Id == i.Key)! as ISushiModel, i.Value));
|
||||
}
|
||||
private init => Sushis = value;
|
||||
}
|
||||
|
||||
public static Store? Create(StoreBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Store()
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreName = model.StoreName,
|
||||
OpeningDate = model.OpeningDate,
|
||||
StoreAddress = model.StoreAddress,
|
||||
_sushi = model.Sushis
|
||||
.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||
maxSushi = model.maxSushi
|
||||
};
|
||||
}
|
||||
|
||||
public static Store? Create(XElement? element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Store()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
StoreName = element.Element("StoreName")!.Value,
|
||||
StoreAddress = element.Element("StoreAddress")!.Value,
|
||||
maxSushi = Convert.ToInt32(element.Element("MaxSushi")!.Value),
|
||||
_sushi = element.Element("Sushis")
|
||||
!.Elements("Sushi")
|
||||
.ToDictionary(
|
||||
x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
x => Convert.ToInt32(x.Element("Value")?.Value)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(StoreBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StoreName = model.StoreName;
|
||||
StoreAddress = model.StoreAddress;
|
||||
_sushi = model.Sushis
|
||||
.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
maxSushi = model.maxSushi;
|
||||
}
|
||||
|
||||
public StoreViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StoreName = StoreName,
|
||||
Sushis = Sushis,
|
||||
StoreAddress = StoreAddress,
|
||||
maxSushi = maxSushi
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Store",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("StoreName", StoreName),
|
||||
new XElement("StoreAddress", StoreAddress),
|
||||
new XElement("MaxSushi", maxSushi),
|
||||
new XElement("Sushis", _sushi.Select(x => new XElement("Sushi",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value))
|
||||
).ToArray())
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user