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 untrusted user who does not match committer: 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;
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 Xunit;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudDb.Model;
using AsbCloudApp.Data.User;
namespace AsbCloudWebApi.IntegrationTests.Controllers.ProcessMapPlan;
@ -194,6 +196,9 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
var startTime = DateTimeOffset.UtcNow;
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);
dbContext.SaveChanges();
@ -216,6 +221,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
dtoUpdate.TopDriveSpeedLimitMax++;
dtoUpdate.TopDriveTorquePlan++;
dtoUpdate.TopDriveTorqueLimitMax++;
dtoUpdate.Author = user;
var dtoInsert = dtoUpdate.Adapt<ProcessMapPlanDrillingDto>();
dtoInsert.Id = 0;
@ -233,6 +239,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
dtoInsert.TopDriveSpeedLimitMax++;
dtoInsert.TopDriveTorquePlan++;
dtoInsert.TopDriveTorqueLimitMax++;
dtoInsert.Author = user;
// act
var result = await client.UpdateOrInsertRange(entity.IdWell, new ProcessMapPlanDrillingDto[] { dtoUpdate, dtoInsert });