예제 #1
0
        private void LoadUI()
        {
            SlotsView     = new ObservableCollection <DataAccess.DataModels.Slot>();
            BlocksView    = new ObservableCollection <Block>();
            SelectedBlock = null;
            _slotsList    = new List <DataAccess.DataModels.Slot>();
            _blocksList   = new List <DataAccess.DataModels.Block>();

            var task1 = Task.Run(async() => _slotsList = await _slotsRepository.GetAllSlotsAsync());
            var task2 = Task.Run(async() => _blocksList = await _blocksRepository.GetAllBlocksAsync());

            var result = Task.WhenAll(task1, task2);

            result.ContinueWith((t) =>
            {
                if (t.IsCompleted)
                {
                    Application.Current.Dispatcher.InvokeAsync(() =>
                    {
                        foreach (var slot in _slotsList)
                        {
                            SlotsView.Add(slot);
                        }
                        foreach (var block in _blocksList)
                        {
                            BlocksView.Add(block);
                        }
                    });
                }
            });
        }
예제 #2
0
        private async Task Load()
        {
            _slotsList = new List <DataAccess.DataModels.Slot>();
            _slotsList = await _slotsRepository.GetAllSlotsAsync();

            _blocksList = new List <DataAccess.DataModels.Block>();
            _blocksList = await _blocksRepository.GetAllBlocksAsync();
        }
        private void LoadUI()
        {
            TotalBlocks    = 0;
            TotalCustomers = 0;
            TotalSlots     = 0;
            TotalStaffs    = 0;
            TotalVIPMember = 0;
            _customersList = new List <Customer>();
            var task1 = Task.Run(async() => _customersList = await _customersRepository.GetAllCustomersAsync());

            _staffsList = new List <Staff>();
            var task2 = Task.Run(async() => _staffsList = await _staffsRepository.GetAllStaffsAsync());

            _blocksList = new List <Block>();
            var task3 = Task.Run(async() => _blocksList = await _blocksRepository.GetAllBlocksAsync());

            var result = Task.WhenAll(task1, task2, task3);

            result.ContinueWith((t) =>
            {
                if (result.IsCompleted)
                {
                    TotalBlocks = _blocksList.Count;
                    _blocksList.ForEach(param => TotalSlots += (int)param.NumberOfSlots);
                    TotalStaffs    = _staffsList.Count;
                    TotalCustomers = _customersList.Count;
                    foreach (var cus in _customersList)
                    {
                        if (cus.isVIP == "Yes")
                        {
                            TotalVIPMember++;
                        }
                    }
                }
            });
        }