Skip to content

Commit 7ecb963

Browse files
committed
Changing the code so when we create a property it automatically assigns the "00. Logbooks" area to said property as it's default now in practice.
1 parent 5931326 commit 7ecb963

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Helpers/BackendConfigurationPropertiesServiceHelper.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Threading.Tasks;
66
using BackendConfiguration.Pn.Infrastructure.Models.Properties;
7+
using BackendConfiguration.Pn.Infrastructure.Models.PropertyAreas;
78
using BackendConfiguration.Pn.Services.BackendConfigurationLocalizationService;
89
using eFormCore;
910
using JetBrains.Annotations;
@@ -168,6 +169,22 @@ public static async Task<OperationResult> Create(PropertyCreateModel propertyCre
168169
// create a new folder for exceeded tasks
169170
await core.FolderCreate(commonTranslations, property.FolderId).ConfigureAwait(false);
170171

172+
var areaTranslation = await backendConfigurationPnDbContext.AreaTranslations
173+
.Where(x => x.Name == "00. Logbøger")
174+
.FirstOrDefaultAsync().ConfigureAwait(false);
175+
if (areaTranslation != null)
176+
{
177+
var propertyAreaUpdateModel = new PropertyAreasUpdateModel
178+
{
179+
Areas = [
180+
new PropertyAreaModel { AreaId = areaTranslation.AreaId, Activated = true }
181+
],
182+
PropertyId = property.Id
183+
};
184+
await BackendConfigurationPropertyAreasServiceHelper.Update(propertyAreaUpdateModel, core,
185+
backendConfigurationPnDbContext, itemsPlanningPnDbContext, userId).ConfigureAwait(false);
186+
}
187+
171188
return new OperationResult(true,
172189
"SuccessfullyCreatingProperties");
173190
}

0 commit comments

Comments
 (0)