Example #1
0
        public CoinModelFactory(IDirtySerializableCacheService serializableCacheService,
                                IDialogService dialogService,
                                IImageReaderService imageReaderService,
                                IImageCacheService imageCacheService)
        {
            if (serializableCacheService == null)
            {
                throw new ArgumentNullException(nameof(serializableCacheService));
            }
            if (dialogService == null)
            {
                throw new ArgumentNullException(nameof(dialogService));
            }
            if (imageReaderService == null)
            {
                throw new ArgumentNullException(nameof(imageReaderService));
            }
            if (imageCacheService == null)
            {
                throw new ArgumentNullException(nameof(imageCacheService));
            }

            _serializableCacheService = serializableCacheService;
            _dialogService            = dialogService;
            _imageReaderService       = imageReaderService;
            _imageCacheService        = imageCacheService;
        }
Example #2
0
        public CoinModel(Coin coin,
                         IDirtySerializableCacheService serializableCacheService,
                         IDialogService dialogService,
                         IImageReaderService imageReaderService,
                         IImageCacheService imageCacheService)
            : base(serializableCacheService)
        {
            _dialogService      = dialogService;
            _imageReaderService = imageReaderService;
            _imageCacheService  = imageCacheService;

            _coin = coin;

            Images        = new ObservableCollection <Image>(coin.Images ?? new List <Image>());
            SelectedImage = Images.FirstOrDefault();

            AddCoinImageCommand    = new RelayCommand <WindowCommandContext>(AddCoinImage);
            RemoveCoinImageCommand = new RelayCommand <WindowCommandContext>(RemoveCoinImage);

            Validator.AddRule(() => Title, () => RuleResult.Assert(!string.IsNullOrWhiteSpace(Title), Resources.ErrorBlankField));
            Validator.AddRule(() => Country, () => RuleResult.Assert(Country != null, Resources.ErrorBlankField));
            Validator.AddRule(() => Currency, () => RuleResult.Assert(Currency != null, Resources.ErrorBlankField));

            Validator.ValidateAll();
        }