diff --git a/IRaCIS.Core.API/Controllers/DownLoadController.cs b/IRaCIS.Core.API/Controllers/DownLoadController.cs index e6b51bbce..f02a0ba35 100644 --- a/IRaCIS.Core.API/Controllers/DownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/DownLoadController.cs @@ -14,6 +14,7 @@ using System; using System.IO; using System.Linq; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; namespace IRaCIS.Core.API.Controllers { @@ -62,7 +63,7 @@ namespace IRaCIS.Core.API.Controllers [HttpGet("CommonDocument/DownloadCommonDoc")] public async Task DownloadCommonFile(string code, [FromServices] IRepository _commonDocumentRepository) { - var doc = _commonDocumentRepository.AsQueryable(true).FirstOrDefault(t => t.Code == code); + var doc = await _commonDocumentRepository.AsQueryable(true).FirstOrDefaultAsync(t => t.Code == code); if (doc == null) { diff --git a/IRaCIS.Core.API/Controllers/FinancialChangeController.cs b/IRaCIS.Core.API/Controllers/FinancialChangeController.cs index 13ef7628b..4ad7234bb 100644 --- a/IRaCIS.Core.API/Controllers/FinancialChangeController.cs +++ b/IRaCIS.Core.API/Controllers/FinancialChangeController.cs @@ -146,7 +146,7 @@ namespace IRaCIS.Core.API.Controllers.Special }, User.FindFirst("id").Value); } } - _costAdjustmentService.CalculateCNY(addOrUpdateModel.YearMonth, addOrUpdateModel.Rate); + await _costAdjustmentService.CalculateCNY(addOrUpdateModel.YearMonth, addOrUpdateModel.Rate); return result; } diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 217ff1e8f..502029487 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -271,7 +271,6 @@ 添加对象 签名Id - 初始化状态对象 @@ -1123,6 +1122,9 @@ isAllSiteUser true : site用户列表,false :Site调研汇总表 + + + @@ -1679,25 +1681,6 @@ - - - 获取项目多选字典 - - Title、Department、Rank、Position、ReadingType、Subspeciality Sponsor CROCompany ReadingStandard ReviewMode ReviewType ProjectState - - - - 根据Key,获取单个字典数组 - - - 根据Type、Key 获取字典 树结构 - - - 删除字典数据 - - - 获取所有字典数据 - 打包医生官方简历 @@ -2178,7 +2161,12 @@ - + + + 修改密码,当前支持旧密码修改密码 + + + 获取用户列表 diff --git a/IRaCIS.Core.Application/Service/Common/DTO/CommonDocumentViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/CommonDocumentViewModel.cs index fa29a9ae7..37d4bc67b 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/CommonDocumentViewModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/CommonDocumentViewModel.cs @@ -15,7 +15,7 @@ namespace IRaCIS.Core.Application.ViewModel public string FileType { get; set; } = String.Empty; public string ModuleType { get; set; } = String.Empty; - public string FullFilePath { get; set; } + public string FullFilePath { get; set; } = String.Empty; public DateTime? DeletedTime { get; set; } diff --git a/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs index 0fb215f5f..d5f94fb10 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs @@ -13,9 +13,9 @@ namespace IRaCIS.Application.Contracts public DateTime UpdateTime { get; set; } public Guid UpdateUserId { get; set; } - public string ConfigType { get; set; } + public string ConfigType { get; set; } = String.Empty; - public string ConfigTypeDes { get; set; } + public string ConfigTypeDes { get; set; } = String.Empty; } diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index 2934a28f5..6ade8ac17 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -104,208 +104,5 @@ namespace IRaCIS.Application.Services - #region old 待废弃 - - /// - /// 获取项目多选字典 - /// - /// Title、Department、Rank、Position、ReadingType、Subspeciality Sponsor CROCompany ReadingStandard ReviewMode ReviewType ProjectState - /// - [HttpPost] - public DicResultDTO GetDictionary(string[] searchArray) - { - var doctorViewList = _dicRepository.ProjectTo(_mapper.ConfigurationProvider).OrderBy(t => t.KeyName) - .ThenBy(t => t.ShowOrder).ToList(); - - var projectDicResult = new DicResultDTO(); - foreach (var searchItem in searchArray) - { - var item = searchItem.Trim(); - var tempDic = new Dictionary(); - doctorViewList.Where(o => o.KeyName == item).ToList().ForEach(o => tempDic.Add(o.Id!.Value, o.Value)); - projectDicResult.DicList.Add(item, tempDic); - } - return projectDicResult; - } - - - public DicResultDTO GetAllDictionary() - { - var list = _dicRepository.ProjectTo(_mapper.ConfigurationProvider).OrderBy(t => t.KeyName) - .ThenBy(t => t.ShowOrder).ToList(); - - var types = list.Select(u => u.KeyName).Distinct(); - - var projectDicResult = new DicResultDTO(); - foreach (var type in types) - { - var tempDic = new Dictionary(); - - //list.Where(o => o.KeyName == type).ToList().ForEach(o => tempDic.Add(o.Id, string.IsNullOrEmpty(o.ValueCN)?o.Value: o.Value + " / " + o.ValueCN)); - list.Where(o => o.KeyName == type).ToList().ForEach(o => tempDic.Add(o.Id!.Value, o.Value)); - - projectDicResult.DicList.Add(type, tempDic); - } - - // //用户类型从字典表 移到另外的表了,现在为了前端不变,在这里获取,给出数据 - - //var userTypes= _userTypeRoleRepository.GetAll().OrderBy(t => t.Order).Select(t => new {t.Id, t.UserType}).ToList(); - //var userTypeDic = new Dictionary(); - //userTypes.ForEach(o => userTypeDic.Add(o.Id, o.UserType)); - - // projectDicResult.DicList.Add("UserType", userTypeDic); - - - return projectDicResult; - } - - /// 根据Key,获取单个字典数组 - [HttpPost] - public PageOutput getDictionarySelectList(DicQueryDTO dicSearchModel) - { - - - var dicQueryable = _dicRepository - .WhereIf(!string.IsNullOrEmpty(dicSearchModel.KeyName), t => t.KeyName == dicSearchModel.KeyName && t.Value != "") - .ProjectTo(_mapper.ConfigurationProvider); - - var pageList = dicQueryable.ToPagedList(dicSearchModel.PageIndex, dicSearchModel.PageSize, dicSearchModel.SortField, dicSearchModel.Asc); - - return pageList; - - } - - /// 根据Type、Key 获取字典 树结构 - public List GetDicTree() - { - var keyNameTypeDistinctList = _dicRepository.Where(t => t.ParentId != null) - .ProjectTo(_mapper.ConfigurationProvider).Distinct().ToList(); - - var treeNodeList = new List(); - var group = keyNameTypeDistinctList.GroupBy(t => t.Type); - foreach (var groupItem in group) - { - var node = new DictionaryTreeNode() - { - Id = Guid.NewGuid(), - KeyName = groupItem.Key, - Type = groupItem.Key, - Children = keyNameTypeDistinctList.Where(t => t.Type == groupItem.Key).Select(t => - new DictionaryTreeNode() - { - Id = Guid.NewGuid(), - KeyName = t.KeyName, - Type = t.Type, - Children = new List() - }).ToList() - }; - treeNodeList.Add(node); - } - return treeNodeList; - } - - - /// 添加或更新字典数据 - //[HttpPost] - //public IResponseOutput AddOrUpdateDictionary(AddOrUpdateDicDTO viewModel) - //{ - // #region 封装前 - // //if (viewModel.Id == null) - // //{ - // // var existItem = _dicRepository.FirstOrDefault(dic => dic.KeyName.Equals(viewModel.KeyName) && dic.Value.Equals(viewModel.Value)); - // // if (existItem != null) - // // { - // // return ResponseOutput.NotOk("The added item has the same name as a sub-item of current categpry. Please modify the name."); - // // } - // // var result = _dicRepository.Add(_mapper.Map(viewModel)); - // // var success = _dicRepository.SaveChanges(); - // // return ResponseOutput.Result(success); - // //} - // //else - // //{ - // // var existItem = _dicRepository.FirstOrDefault(dic => dic.KeyName.Equals(viewModel.KeyName) && dic.Value.Equals(viewModel.Value)); - // // if (existItem != null && existItem.Id != viewModel.Id) - // // { - // // return ResponseOutput.NotOk("The updated item has the same name as a sub-item of current categpry. Please modify the name."); - // // } - // // var updateItem = _dicRepository.FirstOrDefault(t => t.Id == viewModel.Id); - // // _mapper.Map(viewModel, updateItem); - // // var success = _dicRepository.SaveChanges(); - // // return ResponseOutput.Result(success); - // //} - // #endregion - - // var exp = new EntityVerifyExp() - // { - // VerifyExp = dic => dic.KeyName.Equals(viewModel.KeyName) && dic.Value.Equals(viewModel.Value), - // VerifyMsg = "The item has the same name as a sub-item of current categpry" - // }; - - // //var entity = _dicRepository.UseMapper(_mapper).InsertOrUpdate(viewModel, true, exp); - - // return ResponseOutput.Ok(entity.Id); - - //} - - - /// 删除字典数据 - [HttpDelete("{id:guid}")] - public async Task DeleteDictionary(Guid id) - { - if ((await _doctorDictionaryRepository.AnyAsync(t => t.DictionaryId == id)) || - (await _doctorRepository.AnyAsync(t => t.SpecialityId == id|| t.PositionId == id|| t.DepartmentId == id|| t.RankId == id)) - - ) - { - return ResponseOutput.NotOk("This item is referenced by content of the reviewer's resume."); - } - - if (await _trialDictionaryRepository.AnyAsync(t => t.DictionaryId == id) || - await _trialRepository.AnyAsync(t => t.ReviewModeId == id)) - { - return ResponseOutput.NotOk("This item is referenced by content of the trial infomation."); - } - - var success = await _dicRepository.DeleteFromQueryAsync(t => t.Id == id); - return ResponseOutput.Result(success); - } - - /// 获取所有字典数据 - public async Task> getDictionarySelect() - { - return await _dicRepository.Select(t => t.KeyName).Distinct().ToListAsync(); - } - - //[Obsolete] - [NonDynamicMethod] - public DicViewModelDTO GetDetailById(Guid id) - { - var result = _dicRepository.ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(u => u.Id == id).IfNullThrowException(); - return result; - } - - - - public TrialDicSelect GetGenerateTrialCodeDic() - { - var list = _dicRepository.Where(t => t.KeyName == "Phase" || t.KeyName == "IndicationType" || t.KeyName == "DeclarationType").ProjectTo(_mapper.ConfigurationProvider).ToList(); - - return new TrialDicSelect() - { - Phase = list.Where(t => t.KeyName == "Phase").OrderBy(t => t.ShowOrder).ToArray(), - IndicationType = list.Where(t => t.KeyName == "IndicationType").OrderBy(t => t.ShowOrder).ToArray(), - DeclarationType = list.Where(t => t.KeyName == "DeclarationType").OrderBy(t => t.ShowOrder).ToArray() - }; - - } - - - #endregion - - - - - - } } diff --git a/IRaCIS.Core.Application/Service/Common/Interface/IDictionaryService.cs b/IRaCIS.Core.Application/Service/Common/Interface/IDictionaryService.cs index 0c628954a..40d8534a9 100644 --- a/IRaCIS.Core.Application/Service/Common/Interface/IDictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/Interface/IDictionaryService.cs @@ -9,18 +9,6 @@ namespace IRaCIS.Application.Interfaces public interface IDictionaryService { - Task> getDictionarySelect(); - PageOutput getDictionarySelectList(DicQueryDTO dicSearchModel); - - Task DeleteDictionary(Guid id); - DicResultDTO GetDictionary(string[] searchArray); - DicResultDTO GetAllDictionary(); - //IResponseOutput AddOrUpdateDictionary(AddOrUpdateDicDTO viewModel); - - [EasyCachingAble(Expiration = 10)] - List GetDicTree(); - DicViewModelDTO GetDetailById(Guid Id); - - TrialDicSelect GetGenerateTrialCodeDic(); + } } diff --git a/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs b/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs index 305f0c40c..bf4042238 100644 --- a/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs +++ b/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs @@ -39,7 +39,7 @@ namespace IRaCIS.Core.Application.Services [HttpGet("{code}")] public async Task GetSystemBasicData(string code) { - return await _repository.Where(t => t.Code == code).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); + return (await _repository.Where(t => t.Code == code).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); } diff --git a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs index 04f05152c..be67e2c24 100644 --- a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs @@ -22,12 +22,10 @@ namespace IRaCIS.Core.Application.Services public class SystemDocumentService : BaseService, ISystemDocumentService { - private readonly IWebHostEnvironment _hostEnvironment; private readonly IRepository _systemDocumentRepository; - public SystemDocumentService(IWebHostEnvironment hostEnvironment, IRepository systemDocumentRepository) + public SystemDocumentService( IRepository systemDocumentRepository) { - _hostEnvironment = hostEnvironment; _systemDocumentRepository = systemDocumentRepository; } diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index cb215cdce..098f932fa 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -21,17 +21,13 @@ namespace IRaCIS.Core.Application.Services { - private readonly IWebHostEnvironment _hostEnvironment; private readonly IRepository _trialDocumentRepository; - private readonly IRepository _systemDocConfirmedUserRepository; private readonly IRepository _systemDocumentRepository; - public TrialDocumentService(IWebHostEnvironment hostEnvironment, IRepository trialDocumentRepository - , IRepository systemDocConfirmedUserRepository, IRepository systemDocumentRepository) + public TrialDocumentService( IRepository trialDocumentRepository + , IRepository systemDocumentRepository) { - _hostEnvironment = hostEnvironment; _trialDocumentRepository = trialDocumentRepository; - _systemDocConfirmedUserRepository = systemDocConfirmedUserRepository; _systemDocumentRepository = systemDocumentRepository; } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs index e0c2d734d..5126261a9 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs @@ -20,7 +20,7 @@ namespace IRaCIS.Core.Application.Contracts public Guid SubjectVisitId { get; set; } - public string SubjectCode { get; set; } + public string SubjectCode { get; set; } = String.Empty; public string VisitName { get; set; } = string.Empty; @@ -58,12 +58,11 @@ namespace IRaCIS.Core.Application.Contracts public decimal FileSize { get; set; } - public string IP { get; set; } + public string IP { get; set; } = String.Empty; public bool IsDicomReUpload { get; set; } - public bool IsDicom { get; set; } public int FileCount { get; set; } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/Interface/IStudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/Interface/IStudyService.cs index 697f17681..688d155ed 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/Interface/IStudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/Interface/IStudyService.cs @@ -41,7 +41,7 @@ namespace IRaCIS.Application.Interfaces //IEnumerable GetAllRelationStudyList(Guid studyId); - /// 根据项目Id,医生Id,获取受试者访视点(不分页) + //IEnumerable GetStudyStatList(Guid trialId, Guid subjectId, Guid siteId); @@ -72,10 +72,7 @@ namespace IRaCIS.Application.Interfaces //void UploadStudyDeal(Guid studyId); - /// - /// 更新Study 表中的Status,并且往 StudyStatusDetail详情表中插入一条状态变化记录 - /// - /// + //List GetReviewerListByTrialId(Guid trialId); diff --git a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs index d319b59f4..c3c8de073 100644 --- a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs +++ b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs @@ -223,7 +223,7 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO { public string ExperimentName { get; set; } = string.Empty; - public string SiteName { get; set; } = string.Empty; + public string FirstName { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index ab42a0765..cbd59344b 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -260,7 +260,6 @@ namespace IRaCIS.Core.Application.Service.Inspection /// /// 添加对象 /// 签名Id - /// 初始化状态对象 /// public async Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId=null) { diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserTypeRoleModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserTypeRoleModel.cs index 2ca7b8a02..9fd1265d8 100644 --- a/IRaCIS.Core.Application/Service/Management/DTO/UserTypeRoleModel.cs +++ b/IRaCIS.Core.Application/Service/Management/DTO/UserTypeRoleModel.cs @@ -55,9 +55,7 @@ namespace IRaCIS.Core.Application.Contracts public List UserTypeGroupIdList { get; set; } = new List(); - /// 用户类型名称简写/// - //public bool IsInternal { get; set; } - //public UserTypeGroup Type { get; set; } = UserTypeGroup.TrialUser; + } diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 527d20929..0881a2d0a 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -277,7 +277,6 @@ namespace IRaCIS.Application.Services /// /// 修改密码,当前支持旧密码修改密码 /// - /// /// [HttpPost] public async Task ModifyPassword(EditPasswordCommand editPwModel) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs index 1bcbf53f6..72bc2dfd4 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs @@ -167,8 +167,8 @@ namespace IRaCIS.Core.Application.Contracts public Guid SignId { get; set; } - [NotDefault] - public string SignCode { get; set; } + [NotDefault] + public string SignCode { get; set; } = string.Empty; } public class TrialConfigDTO: BasicTrialConfig @@ -240,7 +240,7 @@ namespace IRaCIS.Core.Application.Contracts public bool IsQCQuestionConfirmed { get; set; } - public string TrialStatusStr { get; set; } + public string TrialStatusStr { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs index 7fb52c012..3bb15664a 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs @@ -56,7 +56,7 @@ namespace IRaCIS.Core.Application.ViewModel public DateTime? ConfirmTime { get; set; } - public string RejectReason { get; set; } + public string RejectReason { get; set; } = string.Empty; } ///TrialExternalUserQuery 列表查询参数模型 @@ -102,7 +102,7 @@ namespace IRaCIS.Core.Application.ViewModel public DateTime? ConfirmTime { get; set; } - public string RejectReason { get; set; } + public string RejectReason { get; set; } = string.Empty; } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index c21ca4632..d8e06b2ac 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -34,7 +34,9 @@ namespace IRaCIS.Core.Application.Services /// /// /// isAllSiteUser true : site用户列表,false :Site调研汇总表 - + /// + /// + /// /// /// [HttpGet, Route("{trialId:guid}/{isSiteUserNotAll:bool}")] @@ -67,13 +69,13 @@ namespace IRaCIS.Core.Application.Services if (isSiteUserNotAll) { - exportInfo = await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); + exportInfo = (await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); } else { - var data = await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); + var data = (await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); var groupSelectIdQuery = _trialSiteSurveyRepository.Where(t => t.TrialId == trialId && t.IsDeleted == false) diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index 7c9f92199..368d5f8ac 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -17,11 +17,13 @@ namespace IRaCIS.Core.Application.Services { private readonly IRepository _subjectVisitRepository; private readonly IInspectionService _inspectionService; + private readonly IRepository _subjectRepository; - public SubjectVisitService(IRepository subjectVisitRepository, IInspectionService inspectionService) + public SubjectVisitService(IRepository subjectVisitRepository, IInspectionService inspectionService,IRepository subjectRepository) { _subjectVisitRepository = subjectVisitRepository; this._inspectionService = inspectionService; + _subjectRepository = subjectRepository; } [HttpPost] @@ -52,7 +54,7 @@ namespace IRaCIS.Core.Application.Services svCommand.BlindName = "B" + ((int)(svCommand.VisitNum * 10)).ToString("D3"); - var subject = (await _repository.FirstOrDefaultAsync(t => t.Id == svCommand.SubjectId)).IfNullThrowException(); + var subject = (await _subjectRepository.FirstOrDefaultAsync(t => t.Id == svCommand.SubjectId)).IfNullThrowException(); @@ -206,6 +208,10 @@ namespace IRaCIS.Core.Application.Services { return ResponseOutput.NotOk("This visit is InPlan and couldn't be deleted."); } + if (await _subjectVisitRepository.AnyAsync(t => t.OutPlanPreviousVisitId == id )) + { + return ResponseOutput.NotOk("This visit is OutPlanPreviousVisitId and couldn't be deleted."); + } return ResponseOutput.Result(await _repository.DeleteFromQueryAsync(s => s.Id == id)); }