public void InitializeLibrary() { SongManager.ClearSongs(); Library.Songs.Clear(); foreach (string s in Library.RootPath) { Library.Songs.UnionWith(Directory.EnumerateFiles(s, "*.mp3", SearchOption.AllDirectories)); } foreach (string potentialSong in Library.Songs) { SongManager.CreateSong(Song.New(potentialSong)); } }
public async Task <IActionResult> PostSong([FromForm] SongCreateRequest request) { //if (request.UploadedFile.ContentType != "audio/wave") //{ // return BadRequest("Wrong file type"); //} var identityClaimNum = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var dto = _mapper.Map <SongCreateDTO>(request); dto.OwnerId = identityClaimNum; if (await _manager.CreateSong(dto)) { return(StatusCode(201)); } throw new Exception(); }