Enhanced mapping logic in MappingProfile: - Set Status to Created or Signed in CreateDocStatusCommand mapping based on Value property. - Automatically set StatusChangedWhen to current UTC time in UpdateDocStatusCommand mapping.
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using AutoMapper;
|
|
using EnvelopeGenerator.Application.Common.Extensions;
|
|
using EnvelopeGenerator.Application.DocStatus.Commands;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
|
|
namespace EnvelopeGenerator.Application.DocStatus;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class MappingProfile : Profile
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public MappingProfile()
|
|
{
|
|
CreateMap<CreateDocStatusCommand, DocumentStatus>()
|
|
.ForMember(dest => dest.Envelope, opt => opt.Ignore())
|
|
.ForMember(dest => dest.Receiver, opt => opt.Ignore())
|
|
.ForMember(dest => dest.Status, opt => opt.MapFrom(
|
|
src => src.Value == null
|
|
? Domain.Constants.DocumentStatus.Created
|
|
: Domain.Constants.DocumentStatus.Signed))
|
|
.MapAddedWhen();
|
|
|
|
CreateMap<UpdateDocStatusCommand, DocumentStatus>()
|
|
.ForMember(dest => dest.Envelope, opt => opt.Ignore())
|
|
.ForMember(dest => dest.Receiver, opt => opt.Ignore())
|
|
.ForMember(dest => dest.StatusChangedWhen, opt => opt.MapFrom(src => DateTime.UtcNow))
|
|
.MapChangedWhen();
|
|
}
|
|
} |