/// <summary> /// Create a new Deezer Playlist /// </summary> /// <param name="name">Playlist Name</param> /// <param name="description">(optional) Playlist description</param> /// <returns></returns> public static long CreatePlaylist(string name, string description = "") { CreatePlaylist playlist = new CreatePlaylist() { description = description, songs = false, status = 0, tags = new List <string>(), title = name }; string json = JsonConvert.SerializeObject(playlist, Formatting.Indented); var result = (dynamic)null; string jsonresult = l.DeezerRequest("playlist.create", json); try { result = JsonConvert.DeserializeObject <CreatePlaylistResponse>(jsonresult); } catch (JsonSerializationException) { try { result = JsonConvert.DeserializeObject <dynamic>(jsonresult); throw new Exception("ERROR: " + result.error.VALID_TOKEN_REQUIRED); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result.results); }
public async Task <IHttpActionResult> Post([FromBody] CreatePlaylist command) { await _commandDispatcher.DispatchAsync(command); var playlist = await _playlistService.GetLatesAddedAsync(); return(Created($"api/playlists/{command.Id}", playlist)); }
public HttpResponseMessage Post(NameValueCollection content) { CreatePlaylist cp = new CreatePlaylist(content["name"], content["desc"]); var playlist = Rules.Create.Playlist(cp); //retornar resposta var response = new HttpResponseMessage(HttpStatusCode.SeeOther); response.Headers.Location = new Uri(string.Format("http://localhost:8080{0}", ResolveUri.For(playlist))); return(response); }
private void MenuItem_Click_7(object sender, RoutedEventArgs e) { CreatePlaylist CPL = new CreatePlaylist(); if (CPL.ShowDialog() == true) { Read_XML.Create_XML_Playlist(); Init_Binding(); } }
public async Task <Playlist> CreatePlaylist(string userId, string name, bool?collaborative = false, string description = null) { var builder = new UriBuilder($"{EndpointProvider.Users}/{userId}/playlists"); var payload = new CreatePlaylist { Name = name, Collaborative = collaborative, Description = description }; var response = await HttpService.PostAsync(builder.Uri, TokenService.ApiToken, payload, CancellationToken.None); return(await ProcessResponseMessage <Playlist>(response)); }
public ActionResult NewPost(CreatePlaylist pl) { if (ModelState.IsValid) { int newId = Rules.Create.Playlist(pl, GetCurrentUserName()); if (newId == 0) { ModelState.AddModelError("", "Name must be Unique! Name and Description are required!");//TODO: check element name return(View("Create")); } return(RedirectToAction("Details", new { id = newId })); } return(View("Create")); }
/// <summary> /// Create a new Deezer Playlist /// </summary> /// <param name="name">Playlist Name</param> /// <param name="description">(optional) Playlist description</param> /// <returns></returns> public async Task <long> CreatePlaylistasync(string name, string description = "") { CreatePlaylist playlist = new CreatePlaylist() { description = description, songs = false, status = 0, tags = new List <string>(), title = name }; string json = JsonConvert.SerializeObject(playlist, Formatting.Indented); var result = (dynamic)null; string jsonresult = await Requestasync("playlist.create", json); try { result = JsonConvert.DeserializeObject <CreatePlaylistResponse>(jsonresult); } catch (JsonSerializationException e) { try { if (jsonresult.Contains("QUOTA_ERROR")) { var _i = 0; try { _i = int.Parse(description); if (_i > 5) { throw new JsonSerializationException(e.Message); } } catch (Exception) { } _ = await CreatePlaylistasync(name, (_i += 1).ToString()); } result = JsonConvert.DeserializeObject <dynamic>(jsonresult); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result.results); }
public int Playlist(CreatePlaylist createPlaylist, string user) { string name = createPlaylist.Name; string desc = createPlaylist.Description; if (name.Equals("") || desc.Equals("")) { return(0); } Playlist p = new Playlist(name, desc, user); if (!repo.getAll().Any(existingPlaylist => existingPlaylist.Name.Equals(name))) { int id = repo.put(p); p.id = id; return(id); } return(0); }
public ViewPlaylist Playlist(CreatePlaylist createPlaylist) { string name = createPlaylist.Name; string desc = createPlaylist.Description; if (name.Equals("") || desc.Equals("")) { return(null); } Playlist p = new Playlist(name, desc); Playlist[] matchingPlaylists = repo.getAll(p); if (matchingPlaylists.Length <= 0) { int id = repo.put(p); p.id = id; ViewPlaylist ret = new ViewPlaylist(p.id, p.Name, p.Description, p.Tracks); return(ret); } return(null); }
private void btnCreatePlaylist_Click(object sender, RoutedEventArgs e) { CreatePlaylist NewPlalyst = new CreatePlaylist(); NewPlalyst.Show(); }