Last active
December 15, 2019 11:45
-
-
Save ansariabr/d47687e42401928c47ec8a583365a68d to your computer and use it in GitHub Desktop.
A method to calculate discount based on the time of the day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public decimal CalculateDiscount(decimal totalAmount) | |
{ | |
decimal discountPercentage; | |
if (DateTimeOffset.Now.Hour >= 22 || DateTimeOffset.Now.Hour < 6) | |
discountPercentage = 25; | |
else | |
discountPercentage = 10; | |
return totalAmount - ((totalAmount * discountPercentage) / 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment