diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs b/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs index 18baa2f37..322b1cef5 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs @@ -34,7 +34,7 @@ namespace IRaCIS.Core.Application.AutoMapper .ForMember(d => d.TrialSiteCode, u => u.MapFrom(s => s.TrialSite.TrialSiteCode)); CreateMap() - .ForMember(t => t.TrialRoleName, u => u.MapFrom(d => d.TrialRoleName.Value)) + .ForMember(t => t.TrialRoleName, u => u.MapFrom(d => d.TrialRoleName.Value)) .ForMember(d => d.UserType, u => u.MapFrom(s => s.UserTypeRole.UserTypeShortName)); @@ -61,7 +61,10 @@ namespace IRaCIS.Core.Application.AutoMapper - CreateMap().ForMember(t=>t.TrialSiteSurvey,u=>u.MapFrom(c=>c.TrialSiteSurvey)); + CreateMap() + .ForMember(t=>t.TrialSiteSurvey,u=>u.MapFrom(c=>c.TrialSiteSurvey)) + .ForMember(t => t.TrialRoleName, u => u.MapFrom(d => d.TrialRoleName.Value)) + .ForMember(d => d.UserType, u => u.MapFrom(s => s.UserTypeRole.UserTypeShortName)); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index 96d968371..c56b8a80a 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -127,6 +127,7 @@ namespace IRaCIS.Core.Application.Service addEntity.IsSystemUser = false; addEntity.SystemUserId = newAddUser.Id; + await _trialExternalUseRepository.SaveChangesAsync(); } @@ -151,7 +152,6 @@ namespace IRaCIS.Core.Application.Service }); } - await _trialExternalUseRepository.SaveChangesAsync(); return ResponseOutput.Ok(addEntity.Id.ToString()); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index fbf8f8682..b2ef36bac 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -38,7 +38,7 @@ namespace IRaCIS.Application.Services .WhereIf(!string.IsNullOrWhiteSpace(param.UserRealName), t => (t.User.LastName + " / " + t.User.FirstName).Contains(param.UserRealName)) .ProjectTo(_mapper.ConfigurationProvider); - return await query.ToPagedListAsync(param.PageIndex,param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "UpdateTime" : param.SortField, param.Asc); + return await query.ToPagedListAsync(param.PageIndex, param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "UpdateTime" : param.SortField, param.Asc); } @@ -60,7 +60,7 @@ namespace IRaCIS.Application.Services return await query.ToPagedListAsync(param.PageIndex, param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "UpdateTime" : param.SortField, param.Asc); - + } @@ -96,11 +96,11 @@ namespace IRaCIS.Application.Services { var addArray = _mapper.Map(userTrialCommands); - await _repository.AddRangeAsync(addArray); + var trialUsers = await _trialUseRepository.AddRangeAsync(addArray); - foreach (var item in addArray) + foreach (var item in trialUsers) { - item.JoinTime = item.CreateTime; + item.JoinTime = DateTime.Now; } @@ -115,7 +115,7 @@ namespace IRaCIS.Application.Services [HttpPut] public async Task UpdateTrialUser(UpdateTrialUserCommand updateTrialUserCommand) { - var trialUser = await _trialUseRepository.Where(t => t.Id == updateTrialUserCommand.Id,true,true).FirstOrDefaultAsync(); + var trialUser = await _trialUseRepository.Where(t => t.Id == updateTrialUserCommand.Id, true, true).FirstOrDefaultAsync(); if (trialUser == null) return Null404NotFound(trialUser); diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs index fd8480485..c8fcb93e7 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs @@ -28,6 +28,9 @@ namespace IRaCIS.Core.Infra.EFCore Task CountAsync(Expression> whereLambda = null, bool ignoreQueryFilters = false); ValueTask AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); + + Task> AddRangeAsync(IEnumerable entities); + Task AddRangeAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default); // 不建议使用,使用跟踪,然后save 部分字段更新,此种方式是更新所有字段 Task UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 9c0d98310..6040884df 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -139,7 +139,12 @@ namespace IRaCIS.Core.Infra.EFCore return entity; } + public async Task> AddRangeAsync(IEnumerable entities) + { + await _dbSet.AddRangeAsync(entities).ConfigureAwait(false); + return entities; + } public async Task AddRangeAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default) { await _dbSet.AddRangeAsync(entities).ConfigureAwait(false);