Esempio n. 1
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);
        }
Esempio n. 2
0
        private void Worker_AddToHistory_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (!worker_deleteNotification.IsBusy)
            {
                worker_deleteNotification.RunWorkerAsync(AllNotifications[tempIndex].notification_id);

                AllNotifications.RemoveAt(tempIndex);
            }
            addEntry = false;
        }
 private void UpdateNotificationSet()
 {
     if (CurrentNotificationType != MalNotificationsTypes.Generic)
     {
         Notifications = new ObservableCollection <MalNotification>(AllNotifications.Where(notification => notification.Type == CurrentNotificationType));
     }
     else
     {
         Notifications = new ObservableCollection <MalNotification>(AllNotifications);
     }
 }
Esempio n. 4
0
        public Notification Execute(object obj = null)
        {
            List <Image> dogImages    = (List <Image>)obj;
            var          notification = new Notification();
            var          totalDogs    = _racetrack.GetAllDogsInRacetrack().Count;

            if (totalDogs < maxNumberOfDogsInRacetrack)
            {
                IDog newDog = _racetrack.CreateDog(DogBreedEnum.Greyhound);
                newDog.DogImage = dogImages[totalDogs];
                _racetrack.AddDogToRacetrack(newDog);
                notification.Code        = NotificationEnum.Ok;
                notification.Description = AllNotifications.NewDogToRacetrackOk(newDog.Name.ToString());
                notification.Items       = _racetrack.GetAllDogsInRacetrack().Count();
                return(notification);
            }

            notification.Code        = NotificationEnum.Warning;
            notification.Description = AllNotifications.NewDogToRacetrackWarning();
            notification.Items       = totalDogs;
            return(notification);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 public void TrackDistanceComboBox_SelectionChanged(int selectedItemValue, Label labelNotification)
 {
     racetrackDistance            = selectedItemValue;
     labelNotification.Content    = AllNotifications.DistanceSetOk();
     labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Ok);
 }