Skip to content

Commit

Permalink
Refactored models to only be read-only through abstraction with an in…
Browse files Browse the repository at this point in the history
…terface
  • Loading branch information
jregnier committed Nov 29, 2020
1 parent 2be8c7d commit a9b12df
Show file tree
Hide file tree
Showing 21 changed files with 843 additions and 420 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ IMtgServiceProvider serviceProvider = new MtgServiceProvider();
The result of all service calls resturns a generic **Exception Monad** containing the results of the call.
```cs
CardService service = serviceProvider.GetCardService();
Exceptional<List<Card>> result = service.AllAsync();
Exceptional<List<ICard>> result = service.AllAsync();
if (result.IsSuccess)
{
var value = result.Value;
Expand Down
2 changes: 1 addition & 1 deletion src/MtgApiManager.Lib.Test/Model/CardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void MapCardTest()
Watermark = "watermark"
};

Card model = _modelMapper.MapCard(dto);
var model = _modelMapper.MapCard(dto);

Assert.Equal(dto.Artist, model.Artist);
Assert.Equal(dto.Border, model.Border);
Expand Down
26 changes: 13 additions & 13 deletions src/MtgApiManager.Lib.TestApp/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ namespace MtgApiManager.Lib.TestApp
public class MainViewModel : ViewModelBase
{
private readonly IMtgServiceProvider _serviceProvider;
private ObservableCollection<Card> _cardsCollection = null;
private ObservableCollection<ICard> _cardsCollection = null;
private RelayCommand _cardSearchCommand;
private string _cardSearchString = null;
private RelayCommand _findSelectedCardCommand;
private RelayCommand _findSelectedSetCommand;
private RelayCommand _generateBoosterCommand;
private ObservableCollection<Card> _generatedBoosterCollection = null;
private ObservableCollection<ICard> _generatedBoosterCollection = null;
private RelayCommand _getCardSubTypesCommand;
private RelayCommand _getCardSuperTypesCommand;
private RelayCommand _getCardTypesCommand;
private bool _isLoading = false;
private Card _selectedCard = null;
private ICard _selectedCard = null;
private string _selectedCardId = null;
private Set _selectedSet = null;
private ISet _selectedSet = null;
private string _selectedSetCode = null;
private ObservableCollection<Set> _setsCollection = null;
private ObservableCollection<ISet> _setsCollection = null;
private RelayCommand _setSearchCommand;
private string _setSearchString = null;

private ObservableCollection<string> _typesCollection = null;

public MainViewModel()
{
_cardsCollection = new ObservableCollection<Card>();
_setsCollection = new ObservableCollection<Set>();
_cardsCollection = new ObservableCollection<ICard>();
_setsCollection = new ObservableCollection<ISet>();
_serviceProvider = new MtgServiceProvider();
}

public ObservableCollection<Card> CardsCollection
public ObservableCollection<ICard> CardsCollection
{
get => _cardsCollection;
set => Set(() => CardsCollection, ref _cardsCollection, value);
Expand Down Expand Up @@ -143,7 +143,7 @@ public RelayCommand GenerateBoosterCommand

if (result.IsSuccess)
{
GeneratedBoosterCollection = new ObservableCollection<Card>(result.Value);
GeneratedBoosterCollection = new ObservableCollection<ICard>(result.Value);
}

IsLoading = false;
Expand All @@ -152,7 +152,7 @@ public RelayCommand GenerateBoosterCommand
}
}

public ObservableCollection<Card> GeneratedBoosterCollection
public ObservableCollection<ICard> GeneratedBoosterCollection
{
get => _generatedBoosterCollection;
set => Set(() => GeneratedBoosterCollection, ref _generatedBoosterCollection, value);
Expand Down Expand Up @@ -230,7 +230,7 @@ public bool IsLoading
set => Set(() => IsLoading, ref _isLoading, value);
}

public Card SelectedCard
public ICard SelectedCard
{
get => _selectedCard;
set => Set(() => SelectedCard, ref _selectedCard, value);
Expand All @@ -242,7 +242,7 @@ public string SelectedCardId
set => Set(() => SelectedCardId, ref _selectedCardId, value);
}

public Set SelectedSet
public ISet SelectedSet
{
get => _selectedSet;
set => Set(() => SelectedSet, ref _selectedSet, value);
Expand All @@ -254,7 +254,7 @@ public string SelectedSetCode
set => Set(() => SelectedSetCode, ref _selectedSetCode, value);
}

public ObservableCollection<Set> SetsCollection
public ObservableCollection<ISet> SetsCollection
{
get => _setsCollection;
set => Set(() => SetsCollection, ref _setsCollection, value);
Expand Down
Loading

0 comments on commit a9b12df

Please sign in to comment.