Пример #1
0
        public void BtnAddGuy_Click(ComboBox comboBoxGuys, Label labelNotification, GuyNameEnum guyName)
        {
            ICommand newGuyCommand = _commandInvoker.GetCommand(ActionCommandEnum.NewGuyToPalaceStadium);
            var      notification  = newGuyCommand.Execute(guyName);
            var      allGuys       = (List <IGuy>)_dogRacePalaceStadium.GetAllGuysInTheStadium();

            comboBoxGuys.ItemsSource     = allGuys.Select(a => a.Name).ToList();
            labelNotification.Content    = notification.Description;
            labelNotification.Foreground = NotificationColors.GetBrushColor(notification.Code);
        }
Пример #2
0
        public Notification Execute(object obj = null)
        {
            Notification       notification         = new Notification();
            BettingAccount     bettingAccount       = (BettingAccount)obj;
            GuyNameEnum        betGuyName           = bettingAccount.BettingAccountHolderName;
            DogNameEnum        betDogName           = bettingAccount.BettingDogNameSelected;
            int                betAmount            = bettingAccount.BettingAmount;
            IEnumerable <IGuy> allGuysInTheStadium  = _dogRacePalaceStadium.GetAllGuysInTheStadium();
            IGuy               selectedGuyInStadium = allGuysInTheStadium.Where(a => a.Name == betGuyName).FirstOrDefault();

            if (selectedGuyInStadium == null)
            {
                notification.Description = AllNotifications.NoGuyAddedToTheStadiumWarning();
                notification.Code        = NotificationEnum.Warning;
            }
            else
            {
                var guyCashBalance = selectedGuyInStadium.GetMoneyBalance();
                if (guyCashBalance < betAmount)
                {
                    notification.Description = AllNotifications.BetNotEnoughCashWarning(betGuyName.ToString(), betAmount, (int)guyCashBalance);
                    notification.Code        = NotificationEnum.Warning;
                }
                else
                {
                    selectedGuyInStadium.WithdrawMoney(betAmount);
                    _bettingBank.AddBettingAccountToBettingBank(bettingAccount);

                    notification.Description = ClientValidation.StandardBettingNotification();
                    notification.Code        = NotificationEnum.Ok;
                }
            }
            notification.Items = allGuysInTheStadium.Count();
            return(notification);
        }
Пример #3
0
        public Notification Execute(object obj = null)
        {
            var guyName      = (GuyNameEnum)obj;
            var notification = new Notification();
            var allGuys      = _dogRacePalaceStadium.GetAllGuysInTheStadium();
            var existingGuy  = allGuys.Where(a => a.Name == guyName).FirstOrDefault();

            if (existingGuy != null)
            {
                notification.Code        = NotificationEnum.Warning;
                notification.Description = AllNotifications.GuyAddedToStadiumWarning(existingGuy.Name.ToString());
                notification.Items       = allGuys.Count();
            }
            else
            {
                IGuy newGuy = _dogRacePalaceStadium.CreateGuy(guyName);
                _dogRacePalaceStadium.AddGuyToTheStadium(newGuy);
                notification.Code        = NotificationEnum.Ok;
                notification.Description = AllNotifications.GuyAddedToStadiumOk(newGuy.Name.ToString());
                notification.Items       = _dogRacePalaceStadium.GetAllGuysInTheStadium().Count();
            }
            return(notification);
        }
Пример #4
0
        public Notification Execute(object obj = null)
        {
            var         notification         = new Notification();
            CashDeposit cashDeposit          = (CashDeposit)obj;
            var         allGuysInTheStadium  = _dogRacePalaceStadium.GetAllGuysInTheStadium();
            var         selectedGuyInStadium = allGuysInTheStadium.Where(a => a.Name == cashDeposit.GuyName).FirstOrDefault();

            if (selectedGuyInStadium != null)
            {
                selectedGuyInStadium.SetDeposit(cashDeposit.CashAmount);
                var cashBalance = selectedGuyInStadium.GetMoneyBalance();
                notification.Code        = NotificationEnum.Ok;
                notification.Description = AllNotifications.CashDepositOk(cashDeposit.GuyName.ToString(), (int)cashDeposit.CashAmount, (int)cashBalance);
                notification.Items       = allGuysInTheStadium.Count();
            }
            else
            {
                notification.Code        = NotificationEnum.Warning;
                notification.Description = AllNotifications.NoGuyAddedToTheStadiumWarning();
                notification.Items       = allGuysInTheStadium.Count();
            }
            return(notification);
        }