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); }
public IGuy CreateGuy(GuyNameEnum guyName) { IGuy guy = ContainerConfig.GetInstance <IGuy>(); guy.Name = guyName; guy.SetDeposit(0); return(guy); }
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); }
public void BtnMakeDeposit_Click(Label labelNotification, GuyNameEnum guyName, int amountDeposit) { ICommand makeDepositCommand = _commandInvoker.GetCommand(ActionCommandEnum.DepositMoneyInGuyPocket); CashDeposit deposit = new CashDeposit() { GuyName = guyName, CashAmount = amountDeposit }; var notification = makeDepositCommand.Execute(deposit); labelNotification.Content = notification.Description; labelNotification.Foreground = NotificationColors.GetBrushColor(notification.Code); }
public CommandDepositMoneyInGuyPocket(IDogRacePalaceStadium dogRacePalaceStadium, GuyNameEnum guyName, double depositAmount) { ActionCommand = ActionCommandEnum.DepositMoneyInGuyPocket; _dogRacePalaceStadium = dogRacePalaceStadium; _depositAmount = depositAmount; }
public void BtnPlaceBet_Click(Label LblBetNotification, List <Label> allGuysLabels, ListBox listBoxBetsPlaced, GuyNameEnum guyName, DogNameEnum dogName, int betAmount) { ICommand placeBetCommand = _commandInvoker.GetCommand(ActionCommandEnum.PlaceBet); BettingAccount bettingAccount = new BettingAccount() { BettingAccountHolderName = guyName, BettingDogNameSelected = dogName, BettingAmount = betAmount }; var notification = placeBetCommand.Execute(bettingAccount); LblBetNotification.Content = notification.Description; LblBetNotification.Foreground = NotificationColors.GetBrushColor(notification.Code); listBoxBetsPlaced.ItemsSource = _bettingBank.GetAllBetsAsDescriptions(); UpdateGuysLabels(allGuysLabels); }