Hi, we have a CRUD-Service looking like this
[Authorize(SeoMonitorPermissions.MonitorBlocks.Default)]
public class MonitorBlockAppService :
CrudAppService<
MonitorBlockItem,
MonitorBlockItemDto,
Guid,
MonitorBlockPagedSortedFilteredRequestDto,
CreateUpdateMonitorBlockItemDto>,
IMonitorBlockAppService //implement the IMonitorBlockAppService
{
private readonly IRepository<MonitorBoardItem, Guid> _monitorBoardItemRepository;
private readonly IRepository<MonitorBlockItem, Guid> _monitorBlockItemRepository;
private readonly IRepository<MonitorBlockItemAssignment, Guid> _monitorBlockItemAssignmentRepository;
private readonly IRepository<WebsiteItem, Guid> _websitesRepository;
private readonly IRepository<JobItem, Guid> _jobsRepository;
//private MonitorBlockManager monitorBlockManger;
public MonitorBlockAppService(IRepository<MonitorBlockItem, Guid> repository,
IRepository<MonitorBoardItem, Guid> monitorBoardItemRepository,
IRepository<MonitorBlockItemAssignment, Guid> monitorBlockItemAssignmentRepository,
IRepository<WebsiteItem, Guid> websitesRepository,
IRepository<JobItem, Guid> jobsRepository
)
: base(repository)
{
_monitorBoardItemRepository = monitorBoardItemRepository;
_monitorBlockItemRepository = repository;
_monitorBlockItemAssignmentRepository = monitorBlockItemAssignmentRepository;
_websitesRepository = websitesRepository;
_jobsRepository = jobsRepository;
}
inside there is a CreateAsync-Endpoint looking like this:
[UnitOfWork]
public override async Task<MonitorBlockItemDto> CreateAsync(CreateUpdateMonitorBlockItemDto input)
{
//Create MonitorBlockItem
var currentBlock = await base.CreateAsync(input);
Logger.LogInformation("MonitorBlockServce: Start Writing Assingnements");
try
{
//writing 1:n relations
var blockSiteAssignements = new List<MonitorBlockItemAssignment>();
foreach (var job in input.AssignedJobs)
{
var assignement = new MonitorBlockItemAssignment(job.Id, currentBlock.Id);
blockSiteAssignements.Add(assignement);
}
// await _monitorBlockItemAssignmentRepository.InsertManyAsync(blockSiteAssignements);
}
catch (Exception ex) {
Logger.LogException(ex);
throw ex;
}
Logger.LogInformation("MonitorBlockService: Assingnements written");
Logger.LogInformation("MonitorBlockService: returning Block");
return currentBlock;
}
When we call this endpoint from angular, the request never finsihes. But if we set a breakpoint to " return currentBlock;" it is reached with nearly no delay.
We assume it has something to do with writing into two different repositories within one endpoint call.
How do i fix this behaviour ?
best regards, Steffen Schön