コード例 #1
0
        public async Task AddNewList()
        {
            try {
                var link = await _dialogs.ShowPrompt("Enter a conflict chamber list");

                if (string.IsNullOrEmpty(link))
                {
                    return;
                }

                var name = await _dialogs.ShowPrompt("Enter a name for this list");

                if (string.IsNullOrEmpty(name))
                {
                    return;
                }

                string ccId = null;
                Uri    uri  = default(Uri);
                try
                {
                    uri  = new Uri(link);
                    ccId = CCHelper.GetListId(uri);
                }
                catch (Exception)
                {
                    await _dialogs.ShowAlert("Link entered was invalid.");

                    return;
                }

                // new index is whatever the "count" of the list is, from 0 based indexing
                var created = await _dataService.CreateList(name, ccId, this.ConflictChamberLists.Count);

                this.ConflictChamberLists.Add(created);
                RaisePropertyChanged(nameof(ConflictChamberLists));
            }
            catch (ValidationException ex)
            {
                Console.WriteLine(ex.Message);
                await this._dialogs.ShowAlert(ex.Message);
            }
        }