ProcessMapPlanBaseRepository cut off Autor and Editor navigation properties on insert

This commit is contained in:
ngfrolov 2024-03-15 17:41:19 +05:00
parent 271b9d363d
commit f0e0a829f6
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 15 additions and 0 deletions

View File

@ -64,4 +64,12 @@ public class ProcessMapPlanBaseRepository<TDto, TEntity> : ChangeLogRepositoryAb
dto.Section = entity.WellSectionType.Caption; dto.Section = entity.WellSectionType.Caption;
return dto; return dto;
} }
protected override TEntity Convert(TDto dto)
{
var entity = base.Convert(dto);
entity.Author = null;
entity.Editor = null;
return entity;
}
} }

View File

@ -10,6 +10,8 @@ using AsbCloudWebApi.IntegrationTests.Data;
using Refit; using Refit;
using Xunit; using Xunit;
using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Data.ProcessMaps;
using AsbCloudDb.Model;
using AsbCloudApp.Data.User;
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan; namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
@ -194,6 +196,9 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
var startTime = DateTimeOffset.UtcNow; var startTime = DateTimeOffset.UtcNow;
var dbset = dbContext.Set<ProcessMapPlanDrilling>(); var dbset = dbContext.Set<ProcessMapPlanDrilling>();
var user = dbContext.Set<User>().First().Adapt<UserDto>();
user.Surname = "userSurname";
user.Email = "user@mail.domain";
var entry = dbset.Add(entity); var entry = dbset.Add(entity);
dbContext.SaveChanges(); dbContext.SaveChanges();
@ -216,6 +221,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
dtoUpdate.TopDriveSpeedLimitMax++; dtoUpdate.TopDriveSpeedLimitMax++;
dtoUpdate.TopDriveTorquePlan++; dtoUpdate.TopDriveTorquePlan++;
dtoUpdate.TopDriveTorqueLimitMax++; dtoUpdate.TopDriveTorqueLimitMax++;
dtoUpdate.Author = user;
var dtoInsert = dtoUpdate.Adapt<ProcessMapPlanDrillingDto>(); var dtoInsert = dtoUpdate.Adapt<ProcessMapPlanDrillingDto>();
dtoInsert.Id = 0; dtoInsert.Id = 0;
@ -233,6 +239,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
dtoInsert.TopDriveSpeedLimitMax++; dtoInsert.TopDriveSpeedLimitMax++;
dtoInsert.TopDriveTorquePlan++; dtoInsert.TopDriveTorquePlan++;
dtoInsert.TopDriveTorqueLimitMax++; dtoInsert.TopDriveTorqueLimitMax++;
dtoInsert.Author = user;
// act // act
var result = await client.UpdateOrInsertRange(entity.IdWell, new ProcessMapPlanDrillingDto[] { dtoUpdate, dtoInsert }); var result = await client.UpdateOrInsertRange(entity.IdWell, new ProcessMapPlanDrillingDto[] { dtoUpdate, dtoInsert });