Introduced IHasChangedWhen interface to EnvelopeReceiver and History. Added HasEmailAndName property to EnvelopeReceiver. Updated AutoMapperAuditingExtensions to map ChangedWhen to UTC. Removed redundant using statements and fixed formatting.
24 lines
1.1 KiB
C#
24 lines
1.1 KiB
C#
using AutoMapper;
|
|
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
|
|
|
namespace EnvelopeGenerator.Application.Common.Extensions;
|
|
|
|
/// <summary>
|
|
/// Extension methods for applying auditing timestamps during AutoMapper mappings.
|
|
/// </summary>
|
|
public static class AutoMapperAuditingExtensions
|
|
{
|
|
/// <summary>
|
|
/// Maps <see cref="IHasAddedWhen.AddedWhen"/> to the current UTC time.
|
|
/// </summary>
|
|
public static IMappingExpression<TSource, TDestination> MapAddedWhen<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
|
|
where TDestination : IHasAddedWhen
|
|
=> expression.ForMember(dest => dest.AddedWhen, opt => opt.MapFrom(_ => DateTime.UtcNow));
|
|
|
|
/// <summary>
|
|
/// Maps <see cref="IHasChangedWhen.ChangedWhen"/> to the current UTC time.
|
|
/// </summary>
|
|
public static IMappingExpression<TSource, TDestination> MapChangedWhen<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
|
|
where TDestination : IHasChangedWhen
|
|
=> expression.ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(_ => DateTime.UtcNow));
|
|
} |