From 73fa081d50f0a97fbfc0c480e304ce779fecb522 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Fri, 20 May 2022 16:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/TrialSiteService.cs | 5 +-- .../TrialSiteUser/TrialSiteUser.cs | 3 +- .../Common/AuditingData.cs | 32 ++++++++++++------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index 7d362bef5..6da62003b 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -182,7 +182,7 @@ namespace IRaCIS.Core.Application.Services { var query = _trialSiteUserRepository.Where(t => t.TrialId == trialId && t.SiteId == siteId).IgnoreQueryFilters() .ProjectTo(_mapper.ConfigurationProvider); - + return await query.ToListAsync(); } @@ -290,7 +290,8 @@ namespace IRaCIS.Core.Application.Services await _trialSiteUserRepository.AddRangeAsync(addArray); - return ResponseOutput.Result(await _trialSiteUserRepository.SaveChangesAsync()); + await _trialSiteUserRepository.SaveChangesAsync(); + return ResponseOutput.Result(true); } /// 删除CRC人员 diff --git a/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs b/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs index 0dd12b6ee..2a5844394 100644 --- a/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs +++ b/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs @@ -62,8 +62,7 @@ namespace IRaCIS.Core.Domain.Models [ForeignKey("UserId")] public TrialUser TrialUser { get; set; } - [ForeignKey("UserId")] - public UserType UserTypeRole { get; set; } + } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index d84a5fee1..2b953b003 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -303,7 +303,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var entity = item.Entity as TrialSiteUser; if (entity.TrialSite == null) { - entity.TrialSite= await _dbContext.TrialSite.Where(x => x.TrialId == entity.TrialId&&x.SiteId== entity.SiteId).FirstOrDefaultAsync(); + entity.TrialSite = await _dbContext.TrialSite.Where(x => x.TrialId == entity.TrialId && x.SiteId == entity.SiteId).FirstOrDefaultAsync(); } if (entity.Site == null) @@ -311,16 +311,24 @@ namespace IRaCIS.Core.Infra.EFCore.Common entity.Site = await _dbContext.Site.Where(x => x.Id == entity.SiteId).FirstOrDefaultAsync(); } + var user = new User(); + + + if (entity.User == null) { - entity.User = await _dbContext.User.Where(x => x.Id == entity.UserId).FirstOrDefaultAsync(); + user = await _dbContext.User.Where(x => x.Id == entity.UserId).FirstOrDefaultAsync(); } - - if (entity.UserTypeRole == null) + else { - entity.UserTypeRole = await _dbContext.UserType.Where(x => x.Id == entity.User.UserTypeId).FirstOrDefaultAsync(); + user = entity.User; } + // 这里有问题 + + UserType userType = new UserType(); + userType = await _dbContext.UserType.Where(x => x.Id == user.UserTypeId).FirstOrDefaultAsync(); + await InsertInspection(item, type, x => new DataInspection() { GeneralId = x.Id, @@ -332,13 +340,13 @@ namespace IRaCIS.Core.Infra.EFCore.Common City = entity.Site.City, Country = entity.Site.Country, Status = entity.IsDeleted ? "禁用" : "启用", - UserName = entity.User.UserName, - UserRealName = entity.User.FullName, - UserType= entity.UserTypeRole.UserTypeShortName, - Phone= entity.User.Phone, - Email= entity.User.EMail, - Organization= entity.User.OrganizationName, - + UserName = user.UserName, + UserRealName = user.FullName, + UserType = userType.UserTypeShortName, + Phone = user.Phone, + Email = user.EMail, + Organization = entity.User.OrganizationName, + }); }