first commit

This commit is contained in:
Dhananjaya99
2026-09-28 11:44:26 +05:30
parent 721743ae6b
commit bffc9b1686
424 changed files with 46474 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
namespace Fitness_core_BE.Domain
{
public static class DiscountCalculator
{
public static decimal ComputeDiscountAmount(decimal subtotal, string? discountType, decimal? discountValue)
{
if (string.IsNullOrEmpty(discountType) || discountValue is not decimal value || value <= 0 || subtotal <= 0)
return 0m;
var discount = discountType switch
{
"Percentage" => subtotal * Math.Clamp(value, 0m, 100m) / 100m,
"Flat" => Math.Clamp(value, 0m, subtotal),
_ => 0m
};
return Math.Round(discount, 2);
}
}
}