private async Task CopyAlbumList() { try { AlbumListUpsertRequest request = new AlbumListUpsertRequest() { ListDateCreated = DateTime.Now, UniqueKey = GlobalMethods.GenerateUniqueId(), AlbumListName = LoadedAlbumList.AlbumListName + " - Copied from " + LoadedUserProfile.Username, AlbumListType = "Private", UserId = APIService.loggedProfile.UserId, AlbumListDescription = LoadedAlbumList.AlbumListDescription }; var returned = await _albumListService.Insert <AlbumList>(request); foreach (var item in AlbumsInList) { await _albumListAlbumService.Insert <AlbumListAlbum>(new AlbumListAlbumUpsertRequest() { AlbumId = item.AlbumId, AlbumListId = returned.AlbumListId }); } await Application.Current.MainPage.DisplayAlert("Success", "Album list successfully copied!", "OK"); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } }
private async Task SubmitChanges() { if (!ValidateEmpty()) { await Application.Current.MainPage.DisplayAlert("Error", "No empty fields allowed", "Ok"); } else if (!ValidateName()) { await Application.Current.MainPage.DisplayAlert("Error", "Tracklist name not allowed", "Ok"); } else if (!ValidateKeyLength()) { await Application.Current.MainPage.DisplayAlert("Error", "Maximum length of key is 20", "Ok"); } else { AlbumListUpsertRequest request = new AlbumListUpsertRequest() { ListDateCreated = DateTime.Now, AlbumListName = AlbumListName, UniqueKey = UniqueKey, UserId = APIService.loggedProfile.UserId, AlbumListType = SelectedAlbumListType, AlbumListDescription = AlbumListDescription }; var check = await _albumListService.Get <List <AlbumList> >(new AlbumListSearchRequest() { AlbumListName = AlbumListName, UniqueKey = UniqueKey }); if (check.Where(a => a.AlbumListId != ThisAlbumListId).FirstOrDefault() != null) { await Application.Current.MainPage.DisplayAlert("Error", "Combination already exists. Please change the list name or unique key.", "OK"); return; } await _albumListService.Update <AlbumList>(ThisAlbumListId, request); await Application.Current.MainPage.DisplayAlert("Success", "Changes Submitted", "Ok"); } }
private async Task Submit() { if (!ValidateEmpty()) { await Application.Current.MainPage.DisplayAlert("Error", "Please fill out the required fields (Name and Unique Key)", "OK"); return; } else if (!ValidateInvalidName()) { await Application.Current.MainPage.DisplayAlert("Error", "Invalid list name!", "OK"); return; } else if (!ValidateKeyLength()) { await Application.Current.MainPage.DisplayAlert("Error", "Maximum key length is 20!", "OK"); return; } else { if (IsAlbumList) { AlbumListUpsertRequest request = new AlbumListUpsertRequest() { AlbumListDescription = AlbumListDesc, AlbumListName = Name, AlbumListType = SelectedType, ListDateCreated = DateTime.Now, UniqueKey = UniqueKey, UserId = APIService.loggedProfile.UserId }; var check = await _albumListService.Get <List <AlbumList> >(new AlbumListSearchRequest() { AlbumListName = Name, UniqueKey = UniqueKey }); if (check.Count > 0) { await Application.Current.MainPage.DisplayAlert("Error", "Combination already exists. Please change the list name or unique key.", "OK"); return; } var result = await _albumListService.Insert <AlbumList>(request); await Application.Current.MainPage.DisplayAlert("Success", "New album list successfully added! To customize the list" + " visit the My playlists/Album Lists tab.", "OK"); } else { TracklistUpsertRequest request = new TracklistUpsertRequest() { ListDateCreated = DateTime.Now, TracklistName = Name, TracklistType = SelectedType, UniqueKey = UniqueKey, UserId = APIService.loggedProfile.UserId }; var check = await _tracklistService.Get <List <Tracklist> >(new TracklistSearchRequest() { TracklistName = Name, UniqueKey = UniqueKey }); if (check.Count > 0) { await Application.Current.MainPage.DisplayAlert("Error", "Combination already exists. Please change the list name or unique key.", "OK"); return; } var result = await _tracklistService.Insert <Tracklist>(request); await Application.Current.MainPage.DisplayAlert("Success", "New tracklist successfully added! To customize the list" + " visit the My Tracklists/Album Lists tab.", "OK"); } } }