Exemple #1
0
        protected async override Task OnInitializedAsync()
        {
            listCtgr = await CategoryDataService.GetAllCategories();

            listCurr = await CurrencyDataService.GetAllCurrencies();

            Categories = new ObservableCollection <CategoryViewModel>(listCtgr);
            Currencies = new ObservableCollection <CurrencyViewModel>(listCurr);

            if (SelectedExpenseClaimId != 0)
            {
                ronly = true;
                Items = await ItemDataService.GetAllItems(SelectedExpenseClaimId);

                foreach (var it in Items)
                {
                    it.CategoryName = listCtgr.Find(x => x.Id == it.CategoryId).Name;
                    it.CurrencyName = listCurr.Find(x => x.Id == it.CurrencyId).Name;
                    if (it.ItemId == 0)
                    {
                        it.CategoryName = listCtgr[0].Name;
                        it.CurrencyName = listCurr[0].Name;
                    }
                }
            }
        }
Exemple #2
0
        protected override async Task OnInitializedAsync()
        {
            Employees  = (await EmployeeDataService.GetAllEmployees()).ToList();
            Currencies = (await CurrencyDataService.GetAllCurrencies()).ToList();

            int.TryParse(ExpenseId, out var expenseId);

            if (expenseId != 0)
            {
                Expense = await ExpenseDataService.GetExpenseById(int.Parse(ExpenseId));
            }
            else
            {
                Expense = new Expense()
                {
                    EmployeeId = 1, CurrencyId = 1, Status = ExpenseStatus.Open, ExpenseType = ExpenseType.Other
                };
            }

            CurrencyId = Expense.CurrencyId.ToString();
            EmployeeId = Expense.EmployeeId.ToString();
        }
        protected override async Task OnInitializedAsync()
        {
            int.TryParse(ItemId, out SelectedItemId);
            var listCtgr = await CategoryDataService.GetAllCategories();

            var listCurr = await CurrencyDataService.GetAllCurrencies();

            Categories = new ObservableCollection <CategoryViewModel>(listCtgr);
            Currencies = new ObservableCollection <CurrencyViewModel>(listCurr);

            if (SelectedItemId > 0)
            {
                ItemDetailViewModel = await ItemDataService.GetItemById(SelectedItemId);

                SelectedExpenseClaimId = ItemDetailViewModel.ExpenseClaimId;
                SelectedCategoryId     = ItemDetailViewModel.CategoryId.ToString();
                SelectedCurrencyId     = ItemDetailViewModel.CurrencyId.ToString();
            }
            else
            {
                SelectedCategoryId = Categories.FirstOrDefault().Id.ToString();
                SelectedCurrencyId = Currencies.FirstOrDefault().Id.ToString();
            }
        }
 protected async override Task OnInitializedAsync()
 {
     Currencies = await CurrencyDataService.GetAllCurrencies();
 }