private async void SaveArtist() { string coverArtist = ""; if (absolutePathCover != null) { coverArtist = Utils.Encoder.EncodeBase64(absolutePathCover); } Artist artist = new Artist(); artist.name = TextBox_name_artist.Text; artist.description = TextBox_description_artist.Text; artist.cover = coverArtist; artist.idAccount = idAccount; try { if (await ArtistRepository.CreateArtist(artist)) { SingletonMainWindows.GetSingletonWindow().ItemCreator.Visibility = Visibility.Visible; SingletonSesion.GetSingletonSesion().account.contentCreator = true; MessageBox.Show("Artist created"); SingletonMainWindows.GetSingletonWindow().ReloadArtist(); Window.GetWindow(this).Close(); } else { MessageBox.Show("Error to create artist"); } }catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void SavePersonalTrack() { PersonalTrack personalTrack = new PersonalTrack(null, SingletonSesion.GetSingletonSesion().account.idAccount, TextBox_title_personal_track.Text, TextBox_gender_personal_track.Text, TextBox_album_personal_track.Text, 100, null, false, 0); try { personalTrack = await PersonalTrackRepository.CreatePersonalTrack(personalTrack); TrackAudio trackAudio = new TrackAudio() { IdTrack = personalTrack.idPersonalTrack, TrackName = personalTrack.title, Audio = GetTrackBytes() }; var result = await RpcStreamingService.UploadPersonalTrack(trackAudio); if (result) { MessageBox.Show("Track uploaded"); Window.GetWindow(this).Close(); } else { MessageBox.Show("Connection error", "Please try again"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async void Login(object sender, RoutedEventArgs e) { try { if (ValidateEmptyFields()) { LoginRequest loginRequest = new LoginRequest() { user = TextBox_user.Text, password = PasswordBox_password.Password }; var loginResponse = await AccountRepository.LoginAccount(loginRequest); SingletonSesion.SetSingletonSesion(loginResponse); MainWindow main = new MainWindow(); main.Show(); Window.GetWindow(this).Close(); Console.WriteLine(SingletonSesion.GetSingletonSesion().access_token); } else { MessageBox.Show("Empty fields"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async void ReloadArtist() { if (SingletonSesion.GetSingletonSesion().account.contentCreator) { ItemCreator.Visibility = Visibility.Visible; if (await ArtistRepository.GetArtistOfAccount(SingletonSesion.GetSingletonSesion().account.idAccount)) { Console.WriteLine("Artist profile loaded: " + SingletonArtist.GetSingletonArtist().name); } } }
private void LogOut() { SingletonSesion.CleanSingleton(); SingletonMainWindows.CleanSingleton(); SingletonArtist.CleanSingleton(); StopTrack(); RpcStreamingService.Disconnect(); Login login = new Login(); login.Show(); this.Close(); }
public static void Initialize() { ApiClient = new HttpClient(); ApiClient.BaseAddress = new Uri("http://localhost:6000/"); ApiClient.DefaultRequestHeaders.Accept.Clear(); ApiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); if (SingletonSesion.GetSingletonSesion() != null) { ApiClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue( SingletonSesion.GetSingletonSesion().access_token); } }
public async void InitializeWindow() { SingletonMainWindows.SetSingletonWindow(this); loadProgressTrackTimer = new DispatcherTimer(); loadProgressTrackTimer.Tick += new EventHandler(PrintProgress); loadProgressTrackTimer.Interval = new TimeSpan(0, 0, 0, 1); if (SingletonSesion.GetSingletonSesion().account.contentCreator) { ItemCreator.Visibility = Visibility.Visible; if (await ArtistRepository.GetArtistOfAccount(SingletonSesion.GetSingletonSesion().account.idAccount)) { Console.WriteLine("Artist profile loaded: " + SingletonArtist.GetSingletonArtist().name); } } }
public static async Task <bool> UploadTrackAsync(Track track) { try { byte[] bytes = await RpcStreamingService.GetTrackAudio(track.fileTrack); Player.StopPlayer(); Mp3FileReader mp3Reader = new Mp3FileReader(new MemoryStream(bytes)); waveStream = new WaveChannel32(mp3Reader); waveOutEvent.Init(waveStream); isTrackReady = true; Player.StartPlayer(); TrackRepository.AddPlayToTrack(SingletonSesion.GetSingletonSesion().account.idAccount, track.idTrack); return(true); }catch (Exception ex) { Console.WriteLine(ex); return(false); } }
public static async Task <List <Playlist> > GetPlaylistsOfAccount() { string path = "/account/" + SingletonSesion.GetSingletonSesion().account.idAccount + "/playlist"; List <Playlist> playlists = null; using (HttpResponseMessage response = await ApiServiceReader.ApiClient.GetAsync(path)) { if (response.IsSuccessStatusCode) { playlists = await response.Content.ReadAsAsync <List <Playlist> >(); return(playlists); } else { dynamic objError = await response.Content.ReadAsAsync <dynamic>(); string message = objError.error; throw new Exception(message); } } }
private void LoadProfile() { Account account = SingletonSesion.GetSingletonSesion().account; TextBlock_name_account.Text = account.ToString(); TextBlock_email_account.Text = account.email; TextBlock_username_account.Text = account.userName; TextBlock_birthday_account.Text = account.birthday; TextBlock_gender_account.Text = account.gender; string contentCreator; Console.WriteLine(account.contentCreator); if (account.contentCreator) { contentCreator = "Yes"; Button_be_contentCreator.Visibility = Visibility.Hidden; } else { contentCreator = "No"; } TextBlock_content_creator_account.Text = contentCreator; }
public CreatePlaylistPage() { InitializeComponent(); idAccount = SingletonSesion.GetSingletonSesion().account.idAccount; }