diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 852a75965..8987cd594 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -68,7 +68,10 @@ namespace IRaCIS.Core.Application.Service #endregion CreateMap(); - CreateMap().ForMember(dest => dest.CreateUser, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.CreateUser, opt => opt.Ignore()) + .ForAllMembers(opts => opts.Condition((src, dest, srcMember) => srcMember != null)); + CreateMap(); CreateMap().ForMember(dest => dest.CreateUser, opt => opt.Ignore()); diff --git a/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs b/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs index 4a855e503..a590b98b4 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs @@ -2,6 +2,7 @@ using IRaCIS.Application.Contracts; using IRaCIS.Core.Application.Service.WorkLoad.DTO; using IRaCIS.Core.Domain.Models; +using static IRaCIS.Application.Services.TestService; namespace IRaCIS.Core.Application.Service { @@ -17,7 +18,8 @@ namespace IRaCIS.Core.Application.Service CreateMap().ReverseMap(); - + CreateMap(); + } } diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index d8876bcac..5f37812f2 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -105,18 +105,32 @@ namespace IRaCIS.Application.Services { public Guid TestId { get; set; } - public string TestName { get; set; } + public string? TestName { get; set; } } + public class TestModel2 + { + public Guid TestId { get; set; } + + public string TestName { get; set; } + } + public async Task TestJson() { + var model1 = new TestModel() { TestId = NewId.NextSequentialGuid(), TestName = null }; + var model2 = new TestModel2() { TestId = NewId.NextSequentialGuid(), TestName = "test2" }; + + //_mapper.Map(from, dbEntity); + + var model4= _mapper.Map(model1, model2); + await _trialBodyPartRepository.FirstOrDefaultAsync(); - await _trialBodyPartRepository.Where(t=>t.Trial.Id==Guid.Empty).FirstOrDefaultAsync(); + await _trialBodyPartRepository.Where(t => t.Trial.Id == Guid.Empty).FirstOrDefaultAsync(); return ResponseOutput.Ok(new TestModel(), IRCEmailPasswordHelper.GenerateRandomPassword(10)); } diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj index 8f65510a5..555fa1854 100644 --- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj +++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj @@ -1,7 +1,7 @@  - + net8.0