예제 #1
0
        private static IRegistrationData GetRegistrationData(RegulationType regulationType)
        {
            Console.WriteLine("Enter username");
            var username = Console.ReadLine();

            Console.WriteLine("Enter password");
            var password = Console.ReadLine();

            Console.WriteLine("Enter email");
            var email = Console.ReadLine();

            var regularData = new RegistrationData()
            {
                Username = username,
                Password = password,
                Email    = email
            };

            switch (regulationType)
            {
            case RegulationType.Regular:
                return(regularData);

            case RegulationType.Danish:
                return(GetDanishData(regularData));

            case RegulationType.Polish:
                return(GetPolishData(regularData));

            default:
                throw new NotImplementedException("Not implemented regulation type");
            }
        }
예제 #2
0
        private PersonalDetailsService GetNewService(RegulationType regulation)
        {
            var withdrawService      = new WithdrawService();
            var selfExclusionService = new ExternalSelfExclusionService();

            switch (regulation)
            {
            case RegulationType.Regular:
                return(new RegularPersonalDetailsService(
                           new MastercardDepositService(),
                           withdrawService,
                           selfExclusionService));

            case RegulationType.Danish:
                return(new DanishPersonalDetailsService(
                           new PaypalDepositService(),
                           withdrawService,
                           selfExclusionService));

            case RegulationType.Polish:
                return(new PolishPersonalDetailsService(
                           new MastercardDepositService(),
                           new WithdrawService()));

            default:
                throw new NotImplementedException("regulation type is not implemented");
            }
        }
        public RegistrationService GetService(RegulationType regulation)
        {
            var service = services.FirstOrDefault(x => x.RegulationType == regulation);

            if (service == null)
            {
                service = GetNewService(regulation);
                services.Add(service);
            }

            return(service);
        }
예제 #4
0
        private PersonalDetailsService GetService(RegulationType regulation)
        {
            var service = services.FirstOrDefault(x => x.RegulationType == regulation);

            if (service == null)
            {
                service = GetNewService(regulation);
                services.Add(service);
            }

            return(service);
        }
예제 #5
0
        public void LimitTime(RegulationType regulation, string userId, int amount)
        {
            var service = this.GetService(regulation) as ITimeLimitable;

            if (service != null)
            {
                service.LimitPerMonth(userId, amount);
            }
            else
            {
                Console.WriteLine($"Action restricted for this regulation ${regulation.ToString()}");
            }
        }
예제 #6
0
        public void SelfExclude(RegulationType regulation, string userId, int amount)
        {
            var service = this.GetService(regulation) as ISelfExcludable;

            if (service != null)
            {
                service.SelfExclude(userId, amount);
            }
            else
            {
                Console.WriteLine($"Action restricted for this regulation ${regulation.ToString()}");
            }
        }
예제 #7
0
        public void LimitBetAmount(RegulationType regulation, string userId, decimal amount)
        {
            var service = this.GetService(regulation) as IBettingLimitable;

            if (service != null)
            {
                service.LimitPerDay(userId, amount);
            }
            else
            {
                Console.WriteLine($"Action restricted for this regulation: {regulation.ToString()}");
            }
        }
예제 #8
0
        private static void ProcessAction(int action, RegulationType regulation, IUserData userData)
        {
            PersonalDetailsFacade facade = new PersonalDetailsFacade();

            switch (action)
            {
            case 1:
                Console.WriteLine("Enter bet amount you want to deposit:");
                var depositAmount = (decimal.Parse(Console.ReadLine()));
                facade.Deposit(regulation, userData.Id, depositAmount);
                break;

            case 2:
                Console.WriteLine("Enter withdraw amount you want to deposit:");
                var withdrawAmount = (decimal.Parse(Console.ReadLine()));
                facade.Withdraw(regulation, userData.Id, withdrawAmount);
                break;

            case 3:
                Console.WriteLine("Enter amount of days you want to be self excluded:");
                var days = (int.Parse(Console.ReadLine()));
                facade.SelfExclude(regulation, userData.Id, days);
                break;

            case 4:
                Console.WriteLine("Enter amount of days you want to be available to bet per month:");
                var timeLimit = (int.Parse(Console.ReadLine()));
                facade.LimitTime(regulation, userData.Id, timeLimit);
                break;

            case 5:
                Console.WriteLine("Enter betting limit per day:");
                var betLimit = (decimal.Parse(Console.ReadLine()));
                facade.LimitBetAmount(regulation, userData.Id, betLimit);
                break;

            case 6:
                Console.WriteLine("Enter new password:"******"Wrong key pressed");
                break;
            }
        }
        public IEnumerable <IRegistrationValidator> GetValidators(RegulationType regulationType)
        {
            switch (regulationType)
            {
            case RegulationType.Regular:
                return(GetBaseValidators().Concat(GetRegularValidators()));

            case RegulationType.Danish:
                return(GetBaseValidators().Concat(GetDanishValidators()));

            case RegulationType.Polish:
                return(GetBaseValidators().Concat(GetPolishValidators()));

            default:
                throw new NotImplementedException("Regulation type is not implemented");
            }
        }
        private RegistrationService GetNewService(RegulationType regulation)
        {
            var validators = new ValidatorsFactory().GetValidators(regulation);

            switch (regulation)
            {
            case RegulationType.Regular:
                return(new RegularRegistrationService(validators, repository));

            case RegulationType.Danish:
                return(new DanishRegistrationService(validators, repository,
                                                     new EmailService(),
                                                     new DanishReportService()));

            case RegulationType.Polish:
                return(new PolishRegistrationService(validators, repository,
                                                     new PolishReportService()));

            default:
                throw new NotImplementedException("regulation type is not implemented");
            }
        }
예제 #11
0
 public void Withdraw(RegulationType regulation, string userId, decimal amount)
 {
     this.GetService(regulation).Withdraw(userId, amount);
 }
예제 #12
0
 public void Deposit(RegulationType regulation, string userId, decimal amount)
 {
     this.GetService(regulation).Deposit(userId, amount);
 }
예제 #13
0
 public void UpdateUserDetails(RegulationType regulation, IUserData data)
 {
     this.GetService(regulation).UpdatePassword(data.Id, data.Password);
 }
 public IEnumerable <T> GetByRegulation(RegulationType type)
 {
     return(new List <T>(this.entities.Where(x => x.RegulationType == type)));
 }