From 390cf4555c52227ad1f672b4cdcfc20fa9da01db Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Tue, 10 Aug 2021 22:58:53 +1000 Subject: [PATCH] 6.1.4: e.g. 6.11 Using a Constructor Property in an Implementation Class --- chap6_essential_tools_for_mvc/NinjectDemo/Program.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chap6_essential_tools_for_mvc/NinjectDemo/Program.cs b/chap6_essential_tools_for_mvc/NinjectDemo/Program.cs index 4e013f4..a626bcc 100644 --- a/chap6_essential_tools_for_mvc/NinjectDemo/Program.cs +++ b/chap6_essential_tools_for_mvc/NinjectDemo/Program.cs @@ -35,10 +35,16 @@ namespace NinjectDemo public class DefaultDiscountHelper : IDiscountHelper { - public decimal DiscountSize { get; set; } + private decimal discountRate; + + public DefaultDiscountHelper(decimal discountParam) + { + discountRate = discountParam; + } + public decimal ApplyDiscount(decimal totalParam) { - return (totalParam - (DiscountSize * totalParam)); + return (totalParam - (discountRate / 100m * totalParam)); } } }