From f4fc51b66de0d11a2cdfe0d3ea7485985d1e3ef6 Mon Sep 17 00:00:00 2001 From: Hewt <109787524@qq.com> Date: Fri, 20 Mar 2026 11:05:09 +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 --- .../Reading/Dto/SegmentBindingViewModel.cs | 14 ++++++- .../Reading/Segment/SegmentationService.cs | 37 +++++++++++++------ 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/SegmentBindingViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/SegmentBindingViewModel.cs index 39207ca81..7a934535d 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/SegmentBindingViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/SegmentBindingViewModel.cs @@ -24,9 +24,21 @@ public class SaveSegmentBindingAndAnswerInDto public List BindingList { get; set; } } -public class SaveSegmentBindingDto : SegmentBindingAddOrEdit +public class SaveSegmentBindingDto { public string Answer { get; set; } + + public Guid? QuestionId { get; set; } + + public Guid? RowId { get; set; } + + public Guid? SegmentId { get; set; } + + public Guid? SegmentationId { get; set; } + + public Guid? TableQuestionId { get; set; } + + public Guid VisitTaskId { get; set; } } public class SegmentBindingAddOrEdit diff --git a/IRaCIS.Core.Application/Service/Reading/Segment/SegmentationService.cs b/IRaCIS.Core.Application/Service/Reading/Segment/SegmentationService.cs index af253f806..0300b8d28 100644 --- a/IRaCIS.Core.Application/Service/Reading/Segment/SegmentationService.cs +++ b/IRaCIS.Core.Application/Service/Reading/Segment/SegmentationService.cs @@ -11,6 +11,7 @@ using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Infrastructure.Extention; using System.Threading.Tasks; using IRaCIS.Core.Infra.EFCore; +using Microsoft.Extensions.Logging; namespace IRaCIS.Core.Application.Service; /// @@ -209,23 +210,35 @@ public class SegmentationService(IRepository _segmentationReposito .FirstOrDefaultAsync(); if (binding == null) { - await _segmentBindingRepository.InsertFromDTOAsync(new SegmentBinding + if (item.SegmentationId != null && item.SegmentId != null) { - VisitTaskId = inDto.VisitTaskId, - QuestionId = item.QuestionId, - RowId = item.RowId, - TableQuestionId = item.TableQuestionId, - SegmentId = item.SegmentId, - SegmentationId = item.SegmentationId, - }); + await _segmentBindingRepository.InsertFromDTOAsync(new SegmentBinding + { + VisitTaskId = inDto.VisitTaskId, + QuestionId = item.QuestionId, + RowId = item.RowId, + TableQuestionId = item.TableQuestionId, + SegmentId = item.SegmentId.Value, + SegmentationId = item.SegmentationId.Value, + }); + } + } else { - await _segmentBindingRepository.UpdatePartialFromQueryAsync(x => x.Id == binding.Id, t => new SegmentBinding + if (item.SegmentationId != null && item.SegmentId != null) { - SegmentId = item.SegmentId, - SegmentationId = item.SegmentationId, - }); + await _segmentBindingRepository.UpdatePartialFromQueryAsync(x => x.Id == binding.Id, t => new SegmentBinding + { + SegmentId = item.SegmentId.Value, + SegmentationId = item.SegmentationId.Value, + }); + } + else + { + await _segmentBindingRepository.DeleteFromQueryAsync(x => x.Id == binding.Id); + } + }