diff --git a/IRaCIS.Core.Application/Service/Reading/Segment/SegmentationService.cs b/IRaCIS.Core.Application/Service/Reading/Segment/SegmentationService.cs index cb8eed37b..04f691724 100644 --- a/IRaCIS.Core.Application/Service/Reading/Segment/SegmentationService.cs +++ b/IRaCIS.Core.Application/Service/Reading/Segment/SegmentationService.cs @@ -74,7 +74,12 @@ public class SegmentationService(IRepository _segmentationReposito [HttpPost] public async Task AddOrUpdateSegmentation(SegmentationAddOrEdit addOrEditSegmentation) { - + + if (addOrEditSegmentation.Id != null) + { + + await SaveSegmentationVersionAsync(new SaveSegmentationVersionAsyncInDto() { SegmentationId = addOrEditSegmentation.Id.Value }); + } var entity = await _segmentationRepository.InsertOrUpdateAsync(addOrEditSegmentation, true); return ResponseOutput.Ok(entity.Id.ToString()); } @@ -84,8 +89,8 @@ public class SegmentationService(IRepository _segmentationReposito /// /// /// - [HttpPost] - public async Task SaveSegmentationVersionAsync(SaveSegmentationVersionAsyncInDto inDto) + + private async Task SaveSegmentationVersionAsync(SaveSegmentationVersionAsyncInDto inDto) { var data = await _segmentationRepository.FirstOrDefaultNoTrackingAsync(x => x.Id == inDto.SegmentationId); var segmentList = await _segmentRepository.Where(x => x.SegmentationId == inDto.SegmentationId).OrderBy(x=>x.SegmentNumber).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();