Beispiel #1
0
        protected virtual void InitRestClients()
        {
            RestClient = new RestClient(RootUrl + "api/v1/");
            RestClient.AddDefaultHeader("Authentication", ApiKey);
            RestClient.AddDefaultHeader("X-Api-Key", ApiKey);

            Blacklist         = new ClientBase <BlacklistResource>(RestClient, ApiKey);
            Commands          = new CommandClient(RestClient, ApiKey);
            DownloadClients   = new DownloadClientClient(RestClient, ApiKey);
            Albums            = new AlbumClient(RestClient, ApiKey);
            Tracks            = new TrackClient(RestClient, ApiKey);
            History           = new ClientBase <HistoryResource>(RestClient, ApiKey);
            HostConfig        = new ClientBase <HostConfigResource>(RestClient, ApiKey, "config/host");
            Indexers          = new IndexerClient(RestClient, ApiKey);
            Logs              = new LogsClient(RestClient, ApiKey);
            NamingConfig      = new ClientBase <NamingConfigResource>(RestClient, ApiKey, "config/naming");
            Notifications     = new NotificationClient(RestClient, ApiKey);
            Profiles          = new ClientBase <QualityProfileResource>(RestClient, ApiKey);
            Releases          = new ReleaseClient(RestClient, ApiKey);
            ReleasePush       = new ReleasePushClient(RestClient, ApiKey);
            RootFolders       = new ClientBase <RootFolderResource>(RestClient, ApiKey);
            Artist            = new ArtistClient(RestClient, ApiKey);
            Tags              = new ClientBase <TagResource>(RestClient, ApiKey);
            WantedMissing     = new ClientBase <AlbumResource>(RestClient, ApiKey, "wanted/missing");
            WantedCutoffUnmet = new ClientBase <AlbumResource>(RestClient, ApiKey, "wanted/cutoff");
        }
        /// <summary>
        ///     Recupera del ApiRest los albumes del creador de contenido
        /// </summary>
        /// <param name="idCreadorContenido">El id del creador de contenido a recuperar sus albumes</param>
        /// <returns>Un Task</returns>
        private async Task RecuperarAlbums(int idCreadorContenido)
        {
            try
            {
                _albums = await AlbumClient.GetAlbumsFromContentCreator(idCreadorContenido);

                SinConexionGrid.Visibility = Visibility.Hidden;
                AlbumsListView.Visibility  = Visibility.Visible;
                if (_albums == null)
                {
                    _albums = new List <Album>();
                }
                AlbumsListView.ItemsSource = _albums;
            }
            catch (HttpRequestException)
            {
                SinConexionGrid.Visibility = Visibility.Visible;
                AlbumsListView.Visibility  = Visibility.Hidden;
            }
            catch (Exception ex)
            {
                if (ex.Message == "AuntenticacionFallida")
                {
                    new MensajeEmergente().MostrarMensajeError("No se puede autentican con las credenciales " +
                                                               "proporcionadas, se cerra la sesion");
                    MainWindow.OcultarMenu();
                    MainWindow.OcultarReproductor();
                    NavigationService?.Navigate(new IniciarSesion());
                }
                else
                {
                    new MensajeEmergente().MostrarMensajeError(ex.Message);
                }
            }
        }
        public async Task <AlbumClient> CreateAlbumClient()
        {
            var httpClient = await ConstructHttpClient();

            var albumClient = new AlbumClient(httpClient)
            {
                BaseUrl = _appOptions.ImageRecognitionApiUrl
            };


            return(albumClient);
        }
Beispiel #4
0
        /// <summary>
        ///     Edita un album y guarda su portada
        /// </summary>
        private async void EditarAlbum()
        {
            if (ValidarTamañoNombre() && ValidarAño())
            {
                cancelarButton.IsEnabled       = false;
                registrarAlbumButton.IsEnabled = false;
                var album        = CrearAlbum();
                var albumEditado = false;
                try
                {
                    _albumRegistrado = await AlbumClient.EditAlbum(_albumEditar.id, album);

                    albumEditado = true;
                    if (_rutaImagen != "")
                    {
                        var clientePortadas = new CoversClient();
                        clientePortadas.UploadAlbumCover(_rutaImagen, _albumRegistrado.id);
                    }
                }
                catch (HttpRequestException)
                {
                    new MensajeEmergente().MostrarMensajeError("No se puede conectar al servidor");
                }
                catch (RpcException)
                {
                    new MensajeEmergente().MostrarMensajeError(
                        "No se pudo guardar la imagen de portada, puede subirla " +
                        "mas adelante");
                }
                catch (Exception exception)
                {
                    if (exception.Message == "AuntenticacionFallida")
                    {
                        new MensajeEmergente().MostrarMensajeError("No se pudo autenticar con las credenciales " +
                                                                   "con las que se inicio sesion ");
                        Close();
                    }

                    new MensajeEmergente().MostrarMensajeAdvertencia(exception.Message);
                }

                if (albumEditado)
                {
                    Close();
                }
                cancelarButton.IsEnabled       = true;
                registrarAlbumButton.IsEnabled = true;
            }
        }
Beispiel #5
0
 public async Task OnGetAsync([FromServices] AlbumClient albumClient)
 {
     Albums = await albumClient.GetAlbumsAsync();
 }