public User RegisterClient(string name) { User user = new User(); user.Name = name; Console.WriteLine("What type of client are you?"); foreach (int i in Enum.GetValues(typeof(EOfferType))) { Console.WriteLine($"{i} - {((EOfferType)i).ToString() }"); } int option = Int32.Parse(Console.ReadLine()); EOfferType eOfferType = EOfferType.Regular; if (Enum.IsDefined(typeof(EOfferType), option)) { eOfferType = (EOfferType)option; } user.OfferType = eOfferType; Console.WriteLine("Thank you. A waiter will serve you soon"); return(_repository.Insert(user)); }
public IDiscountStrategy GetStrategy(EOfferType offerType) { if (offerType == EOfferType.Loyal) { return(strategyContext[nameof(LoyaltyDicount)]); } else if (offerType == EOfferType.Student) { return(strategyContext[nameof(StudentDiscount)]); } return(strategyContext[nameof(NoDiscountStartegy)]); }
public double ApplyStrategy(EOfferType offerType) { var strategy = GetStrategy(offerType); Console.WriteLine($"You get {strategy.GetType().Name}"); Console.WriteLine("Price before offer: " + price); double finalPrice = price - (price * strategy.GetDiscountPercetange()); Console.WriteLine("Price after offer: " + finalPrice); return(finalPrice); }
public User(string name, EOfferType offerType = EOfferType.Regular) { Name = name; OfferType = offerType; }