Skip to content

Commit

Permalink
refactor: add custom getter for creation date
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-almeida-konkconsulting committed Jun 25, 2024
1 parent ff9b7f0 commit 16ecb86
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ public class Challenge
public required DateTime ExpiresAt { get; set; }
public required string? CreatedBy { get; set; }

public DateTime GetDateOfCreation()
{
return ExpiresAt.AddMinutes(-EXPIRY_TIME_IN_MINUTES);
}

public static Expression<Func<Challenge, bool>> WasCreatedInIntervalBy(DateTime from, DateTime to, string identityAddress)
{
return c => c.ExpiresAt.AddMinutes(-EXPIRY_TIME_IN_MINUTES) > from && c.ExpiresAt.AddMinutes(-EXPIRY_TIME_IN_MINUTES) < to && c.CreatedBy == identityAddress;
return c => c.GetDateOfCreation() > from && c.GetDateOfCreation() < to && c.CreatedBy == identityAddress;
}
}

0 comments on commit 16ecb86

Please sign in to comment.