private async Task LoadCmbGenres() { bool isPending = (entity != null && entity.Status == ReviewStatus.Pending); var request = new Model.Requests.GenresSearchRequest { Filter = isPending ? (int)ReviewStatus.FilterPendingApproved : (int)ReviewStatus.Approved }; var list = await _serviceGenres.Get <List <Model.Genres> >(request); if (isPending) { foreach (var item in list) { if (item.Status == ReviewStatus.Pending) { item.Name = "(PENDING) " + item.Name; } } } cmbGenre.DataSource = list; cmbGenre.ValueMember = "Id"; cmbGenre.DisplayMember = "Name"; }
public async Task LoadGenres() { ItemList.Clear(); var request = new Model.Requests.GenresSearchRequest { Filter = (int)Model.ReviewStatus.Approved }; var list = await _serviceGenres.Get <List <Model.Genres> >(request); foreach (var item in list) { if (item.NumberOfSongs != 0) { ItemList.Add(item); } } }
private async Task loadGenres() { var request = new Model.Requests.GenresSearchRequest { Name = txtSearch.Text, Filter = (cmbStatusFilter.SelectedItem as FilterItem).Id }; var list = await _serviceGenres.Get <List <Model.Genres> >(request); foreach (var item in list) { if (item.Status == Model.ReviewStatus.Rejected) { item.Status = Model.ReviewStatus.Pending; } } dgvGenres.AutoGenerateColumns = false; dgvGenres.DataSource = list; }
public List <Model.Genres> Get([FromQuery] Model.Requests.GenresSearchRequest request) { return(_service.Get(request)); }
private async Task SaveNotation() { if (ArtistId == 0) { // create artist var request = new Model.Requests.ArtistsInsertRequest { Name = ArtistName }; var artist = await _serviceArtists.Insert <Model.Artists>(request); if (artist != null) { ArtistId = artist.Id; } else { await Application.Current.MainPage.DisplayAlert("Error", "Failed to create artist.", "OK"); return; } } if (AlbumId == 0) { // create album var request = new Model.Requests.AlbumsInsertRequest { Name = AlbumName, ArtistId = ArtistId }; var album = await _serviceAlbums.Insert <Model.Albums>(request); if (album != null) { AlbumId = album.Id; } else { await Application.Current.MainPage.DisplayAlert("Error", "Failed to create album.", "OK"); return; } } if (SongId == 0) { int GenreId; var GenreRequest = new Model.Requests.GenresSearchRequest { Name = "Unknown" }; var genre = await _serviceGenres.Get <List <Model.Genres> >(GenreRequest); if (genre.Count == 0) { // Genre "Unknown" does not exist in database var GenreInsertRequest = new Model.Requests.GenresInsertRequest { Name = "Unknown" }; var GenreResult = await _serviceGenres.Insert <Model.Genres>(GenreInsertRequest); if (GenreRequest != null) { GenreId = GenreResult.Id; } else { await Application.Current.MainPage.DisplayAlert("Error", "Failed to create genre.", "OK"); return; } } else { GenreId = genre[0].Id; } // create song var request = new Model.Requests.SongsInsertRequest { Name = SongName, AlbumId = AlbumId, ArtistId = ArtistId, GenreId = GenreId }; var song = await _serviceSongs.Insert <Model.Songs>(request); if (song != null) { SongId = song.Id; } else { await Application.Current.MainPage.DisplayAlert("Error", "Failed to create song.", "OK"); } } if (SongId == 0) { await Application.Current.MainPage.DisplayAlert("Error", "Song is required.", "OK"); return; } Notation.SongId = SongId; var entity = await _serviceNotations.Insert <Model.Notations>(Notation); if (entity != null) { await Application.Current.MainPage.DisplayAlert("Success", "The notation is waiting approval.", "OK"); await _navigation.PopAsync(); } else { await Application.Current.MainPage.DisplayAlert("Error", "Failed to create notation.", "OK"); } }