Exemple #1
0
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                DatasetParty.Clear();
                var dataset = await DataStore.GetAllAsync_Character(true);

                var datasett = await DataStore.GetPartyAsync_Character(true);

                foreach (var data in dataset)
                {
                    Dataset.Add(data);
                }
                foreach (var data in datasett)
                {
                    DatasetParty.Add(data);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                DatasetParty.Clear();
                var dataset = await DataStore.GetAllAsync_Character(true);

                dataset = dataset
                          .OrderBy(a => a.Level)
                          .ThenBy(a => a.Name)
                          .ThenBy(a => a.Speed)
                          .ThenByDescending(a => a.MaximumHealth)
                          .ToList();

                // var datasett = await DataStore.GetPartyAsync_Character(true);
                foreach (var data in dataset)
                {
                    Dataset.Add(data);
                }
                Dataset = new ObservableCollection <Character>(Dataset.OrderBy(a => a.Level)
                                                               .ThenBy(a => a.Name)
                                                               .ThenBy(a => a.Speed)
                                                               .ThenByDescending(a => a.MaximumHealth)
                                                               .ToList());
                foreach (var data in dataset)
                {
                    if (PartyList.Contains(data.Id))
                    {
                        DatasetParty.Add(data);
                    }
                    //DatasetParty = new ObservableCollection<Character>(DatasetParty.OrderBy(a => a.Level)
                    //.ThenBy(a => a.Name)
                    //.ThenBy(a => a.Speed)
                    //.ThenByDescending(a => a.MaximumHealth)
                    //.ToList());
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        //__________________PARTY LOGIC_______________________________________________________
        //add to party
        public async Task <bool> AddToParty(Character character)
        {
            var myData = Dataset.FirstOrDefault(arg => arg.Id == character.Id);

            if (myData == null)
            {
                return(false);
            }
            if (PartyList.Count < 6)
            {
                PartyList.Add(character.Id);
                DatasetParty.Add(character);
                _needsRefresh = true;
                return(true);
            }
            return(false);
        }