череп
This commit is contained in:
parent
d8f88aca87
commit
9ccb8fdba2
@ -14,9 +14,9 @@
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BeautySalonContracts\BeautySalonContracts.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonContracts\BeautySalonContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -7,8 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BeautySalonDataModels\BeautySalonDataModels.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonContracts\BusinessLogicContracts.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonDataModels\BeautySalonDataModels.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonContracts\BusinessLogicContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -32,16 +32,17 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
|
||||
[ForeignKey("CosmeticId")]
|
||||
|
||||
private Dictionary<int, string>? _procedureCosmetics = null;//Это поле для хранения словаря OrderCosmetics.
|
||||
private Dictionary<int, (IProcedureModel, int)>? _procedureCosmetics = null;//Это поле для хранения словаря OrderCosmetics.
|
||||
[NotMapped]
|
||||
public Dictionary<int, string> ProcedureCosmetic//представляет список косметики, участвующей в заказе. Не присутствует в базе данных.
|
||||
public Dictionary<int, (IProcedureModel, int)> ProcedureCosmetic//представляет список косметики, участвующей в заказе. Не присутствует в базе данных.
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_procedureCosmetics == null)
|
||||
{
|
||||
_procedureCosmetics = Procedures
|
||||
.ToDictionary(recPC => recPC.ProcedureId, recPC => recPC.Procedure.ProcedureName);
|
||||
.ToDictionary(recPC => recPC.ProcedureId, recPC =>
|
||||
(recPC.Procedure as ICosmeticModel, recPC.Count));
|
||||
}
|
||||
return _procedureCosmetics;
|
||||
}
|
||||
@ -90,24 +91,24 @@ namespace BeautySalonDatabaseImplement.Models
|
||||
LaborCostId = LaborCostId
|
||||
};
|
||||
|
||||
public void UpdateProcedure(BeautySalonDatabase context, CosmeticBindingModel model)
|
||||
public void UpdateProcedures(BeautySalonDatabase context, CosmeticBindingModel model)
|
||||
{
|
||||
var procedureCosmetic = context.CosmeticProcedures.Where(rec => rec.CosmeticId == model.Id).ToList();
|
||||
if (CosmeticProcedures != null && cosmeticProcedures.Count > 0)
|
||||
var cosmeticProcedures = context.CosmeticProcedures.Where(rec => rec.CosmeticId == model.Id).ToList();
|
||||
if (cosmeticProcedures != null && cosmeticProcedures.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.CosmeticProcedures.RemoveRange(cosmeticProcedures.Where(rec => !model.CosmeticProcedure.ContainsKey(rec.ProcedureId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateProcedure in procedureCosmetic)
|
||||
foreach (var updateProcedure in cosmeticProcedures)
|
||||
{
|
||||
model.CosmeticProcedures.Remove(updateProcedure.CosmeticId);
|
||||
model.CosmeticProcedure.Remove(updateProcedure.CosmeticId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var cosmetic = context.Cosmetics.First(x => x.Id == Id);
|
||||
foreach (var rp in model.CosmeticProcedures)
|
||||
foreach (var rp in model.CosmeticProcedure)
|
||||
{
|
||||
context.CosmeticProcedures.Add(new Procedure
|
||||
context.CosmeticProcedures.Add(new CosmeticProcedure
|
||||
{
|
||||
Cosmetic = cosmetic,
|
||||
Procedure = context.Procedures.First(x => x.Id == rp.Key),
|
||||
|
Loading…
Reference in New Issue
Block a user