Escali License control 1
CurrencyViewModel.cs
Gå til dokumentasjonen til denne filen.
1using AutoMapper;
7using Microsoft.EntityFrameworkCore;
8
10{
12 {
14
15 public List<CurrencyClientModel>? Currencies;
16
17 public CurrencyViewModel(DataContext context, IMapper mapper)
18 {
20 _mapper = mapper;
21 }
22
23 public async Task GetCurrencies()
24 {
25 var currencies = await _currencyService.GetAllCurrencies();
26 UpdateCurrencies(_mapper.Map<List<CurrencyClientModel>>(currencies));
27 }
28
29 private void UpdateCurrencies(List<CurrencyClientModel> currencies)
30 {
31 Currencies = currencies;
33 }
34
35 }
36}
var context
Definition: Program.cs:49
CurrencyViewModel(DataContext context, IMapper mapper)
void UpdateCurrencies(List< CurrencyClientModel > currencies)
CurrencyService class inserts and updates Currency in the Database
async Task< List< Currency > > GetAllCurrencies()
Read all Currencies from database