Refactor: Replace EnvelopeTypeId with EnvelopeType enum
Replaced all instances of `EnvelopeTypeId` (int/int?) with `Type` (EnvelopeType/EnvelopeType?) across the codebase to improve type safety and readability. Updated affected properties, methods, and logic in DTOs, commands, handlers, and Razor components. Introduced conditional compilation to handle differences between .NET and .NET Framework where necessary. Removed obsolete helper methods for `EnvelopeTypeId`. This refactor ensures consistent use of the strongly-typed `EnvelopeType` enum, reducing the risk of invalid values and aligning with best practices.
This commit is contained in:
@@ -9,7 +9,12 @@ namespace EnvelopeGenerator.Domain.Interfaces
|
||||
{
|
||||
public interface IEnvelope
|
||||
{
|
||||
int? EnvelopeTypeId { get; set; }
|
||||
#if NET
|
||||
|
||||
public EnvelopeType? Type { get; set; }
|
||||
#elif NETFRAMEWORK
|
||||
int EnvelopeTypeId { get; set; }
|
||||
#endif
|
||||
|
||||
byte[]
|
||||
#if nullable
|
||||
@@ -22,35 +27,27 @@ namespace EnvelopeGenerator.Domain.Interfaces
|
||||
{
|
||||
public static bool IsReadAndConfirm(this IEnvelope envelope)
|
||||
{
|
||||
return envelope.EnvelopeTypeId == 2;
|
||||
#if NET
|
||||
|
||||
return envelope.Type == EnvelopeType.ReadAndConfirm;
|
||||
#elif NETFRAMEWORK
|
||||
return envelope.EnvelopeTypeId == (int)EnvelopeType.ReadAndConfirm;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool IsReadAndSign(this IEnvelope envelope)
|
||||
{
|
||||
return envelope.EnvelopeTypeId != 2;
|
||||
#if NET
|
||||
|
||||
return envelope.Type != EnvelopeType.ReadAndConfirm;
|
||||
#elif NETFRAMEWORK
|
||||
return envelope.EnvelopeTypeId != (int)EnvelopeType.ReadAndConfirm;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool IsBurned(this IEnvelope envelope)
|
||||
{
|
||||
return envelope.DocResult != null;
|
||||
}
|
||||
|
||||
public static EnvelopeType? Type(this IEnvelope envelope)
|
||||
{
|
||||
if (envelope.EnvelopeTypeId is int envelopeTypeId)
|
||||
return envelopeTypeId.ToEnvelopeType();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SetType(this IEnvelope envelope, EnvelopeType type)
|
||||
{
|
||||
envelope.EnvelopeTypeId = (int)type;
|
||||
}
|
||||
|
||||
public static TEnvelope WithType<TEnvelope>(this TEnvelope envelope, EnvelopeType type) where TEnvelope : IEnvelope
|
||||
{
|
||||
envelope.SetType(type);
|
||||
return envelope;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user