コード例 #1
0
        private async Task RefreshCharacterProfessions()
        {
            CharacterProfessions.Clear();
            CharacterProfessionsName.Clear();
            var characterProfessionApiServises = new CharacterProfessionApiServises();
            var characterProfessions           = await characterProfessionApiServises.SelectCharacterProfessionsAsync();

            var sortedCharacterProfessions = from cP in characterProfessions
                                             orderby cP.Name
                                             select cP;

            foreach (var characterProfession in sortedCharacterProfessions)
            {
                CharacterProfessionsName.Add(characterProfession.Name);
                CharacterProfessions.Add(characterProfession);
            }
        }
コード例 #2
0
        async private void CreateProfessionClick(object sender, EventArgs e)
        {
            if (NameForm.Text == null)
            {
                var toastmessage = "Need to fill name";
                DependencyService.Get <ToastMessage>().ShortTime(toastmessage);
            }
            else
            {
                var characterProfessionApiServise = new CharacterProfessionApiServises();

                var content = await characterProfessionApiServise.AddCharacterProfessionAsync(NameForm.Text, DescriptionForm.Text);

                if (content != null)
                {
                    await Shell.Current.GoToAsync("..");
                }
                else
                {
                    var toastmessage = "Not Created";
                    DependencyService.Get <ToastMessage>().ShortTime(toastmessage);
                }
            }
        }
コード例 #3
0
        public async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Professions.Clear();
                var professionsApiServises = new CharacterProfessionApiServises();
                var professions            = await professionsApiServises.SelectCharacterProfessionsAsync();

                foreach (var profession in professions)
                {
                    Professions.Add(profession);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }