public string this[string propertyName]
        {
            get
            {
                var result = string.Empty;

                if (propertyName.Equals("Sequence"))
                {
                    var derbyId = _division.DerbyId;
                    if (derbyId == 0)
                    {
                        derbyId = _derbyDataService.GetCurrentDerby().DerbyId;
                    }

                    var numberOfDivisionsWithThisSequence = _derbyDataService
                                                            .CheckSequenceNumberUnique(derbyId, _division.DivisionId, _division.Sequence);
                    if (numberOfDivisionsWithThisSequence > 0)
                    {
                        result = "Sequence number must be unique.  Please select another sequence number.";
                    }
                }

                if (result == string.Empty)
                {
                    result = _division[propertyName];
                }

                IsValid = result == string.Empty;
                return(result);
            }
        }
Example #2
0
        public RacerViewModel(IDerbyDataService derbyDataService, IDialogService dialogService)
        {
            _derbyDataService = derbyDataService;
            _dialogService    = dialogService;

            // TODO- update the derby (or at least DerbyId) when a new derby is created
            _currentDerby = _derbyDataService.GetCurrentDerby();
            LoadData();

            LoadCommands();

            Messenger.Default.Register <UpdateListMessage>(this, OnUpdateListMessageRecieved);
        }
        public RacerDetailViewModel(IDerbyDataService derbyDataService)
        {
            _derbyDataService = derbyDataService;

            var currentDerby = _derbyDataService.GetCurrentDerby();

            _divisions = _derbyDataService.GetAllDivisionsExceptChampionship(currentDerby.DerbyId);

            Messenger.Default.Register <Racer>(this, LoadRacer);

            AddDivisionCommand    = new CustomCommand(AddDivision, CanAddRemoveDivision);
            RemoveDivisionCommand = new CustomCommand(RemoveDivision, CanAddRemoveDivision);
            SaveCommand           = new CustomCommand(SaveRacer, CanSaveRacer);
            SaveAndAddCommand     = new CustomCommand(SaveAndAddRacer, CanSaveRacer);
            CancelCommand         = new CustomCommand(CancelRacer, CanCancel);
        }