From fcff424770f65ab44a5af22f000a97e1effb465e Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 29 Mar 2023 13:04:47 +0200 Subject: [PATCH] inizio definizione automatica door types --- .../Controllers/WebDoorCreatorController.cs | 32 +++++++++++++++++++ .../DoorDef/DoorSizingStep.razor.cs | 2 ++ .../Data/WebDoorCreatorService.cs | 13 ++++++++ 3 files changed, 47 insertions(+) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index 7e9fdfe..06637a4 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -507,6 +507,7 @@ namespace WebDoorCreator.Data.Controllers } return fatto; } + /// /// Adding a new graphic param /// @@ -534,5 +535,36 @@ namespace WebDoorCreator.Data.Controllers } #endregion Components Methods + + #region Door Operationm Methods + + + /// + /// Adding a new DoorOpType + /// + /// Record to add + /// + public async Task DoorOpTypeAdd(DoorOpTypeModel addRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetDoorOpType + .Add(addRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorOpTypeAdd: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + #endregion Door Operationm Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs index dcdf55a..99c311a 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs @@ -57,6 +57,8 @@ namespace WebDoorCreator.UI.Components.DoorDef { ListSwings = await WDService.ListValuesGetAll("Opening", "Swing"); ListEdges = await WDService.ListValuesGetAll("Edges", "EdgeType"); + + } protected override async Task OnInitializedAsync() diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index 385bdd3..a05275c 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -9,6 +9,7 @@ using WebDoorCreator.Data.DbModels; using WebDoorCreator.Core; using System.Security.AccessControl; using WebDoorCreator.Data; +using Microsoft.EntityFrameworkCore; namespace WebDoorCreator.UI.Data { @@ -678,6 +679,18 @@ namespace WebDoorCreator.UI.Data listGraphicParams = await SetGraphicParams(file, match, n, i); n++; } + + DoorOpTypeModel doorOpType = new DoorOpTypeModel() + { + Description = $"DOOR OPERATION TYPE FOR {compoNameSplit[1].ToString()}", + HasHw = true, + IsConcrete = true, + HwCode = compoNameSplit[0].ToString(), + DoorOpIdPathFromPatriarch = HierarchyId.Parse("/1/"), + JsoncConfig = JsonConvert.SerializeObject(listGraphicParams) + }; + + await dbController.DoorOpTypeAdd(doorOpType); } i++; }