예제 #1
0
        /// <inheritdoc/>
        public async Task <bool> DeleteAsync(string id)
        {
            var accesstoken = await _accountManager.GetCatalogueTokenAsync();

            if (id == null ||
                string.IsNullOrWhiteSpace(accesstoken))
            {
                return(false);
            }

            try
            {
                var url = _mySoundsUrl + $"/{id}";

                using var msg             = new HttpRequestMessage(HttpMethod.Delete, url);
                msg.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accesstoken);
                var response = await _client.SendAsync(msg);

                if (response.IsSuccessStatusCode)
                {
                    SoundDeleted?.Invoke(this, id);
                }

                return(response.IsSuccessStatusCode);
            }
            catch
            {
                // TODO log
                return(false);
            }
        }
예제 #2
0
 private void OnDeleteClick(object sender, EventArgs e)
 {
     if (File.Exists(_path))
     {
         File.Delete(_path);
         UpdateScreen();
         if (SoundDeleted != null)
         {
             SoundDeleted.Invoke(this, null);
             UsageReporter.SendNavigationNotice("AudioDeleted");
         }
     }
 }