public static void FinishUpload(string temporaryFileName, Music music) { if (music.Id == 0 || string.IsNullOrEmpty(music.Name) || music.ChannelId == 0) { throw new ApplicationException("Uploaded data is invalid { Id:" + music.Id + ", Name:" + music.Name + ", Channel:" + music.ChannelId + " }."); } // Creates channel's directory, if it doesn't exist already. var path = TryToCreateDirectory(music.ChannelId.ToString()); // Finally, move file to correct destination. var fileRealName = Path.ChangeExtension(music.Id.ToString(), Path.GetExtension(music.Name)); path = Path.Combine(path, fileRealName); try { File.Copy(temporaryFileName, path); File.Delete(temporaryFileName); } catch (IOException) { } }
public static FileInfo GetFileInfo(Music music) { return GetFileInfo(TranslateLocalFileName(music)); }
public static string TranslateLocalFileName(Music music) { return ContextualizedPath( DEFAULT_DIRECTORY, music.ChannelId.ToString(), Path.ChangeExtension( music.Id.ToString(), Path.GetExtension(music.Name)) ); }
public static void TryToRemoveMusic(Music music) { TryToRemove(ContextualizedPath(DEFAULT_DIRECTORY, music.ChannelId.ToString(), music.Id.ToString())); }
public void Update(Music c) { if (c.Id != Id) { throw new ApplicationException("Cannot update a music with Id that does not match the view-model Id."); } c.Name = Name; }
public MusicStreamProvider(Music music, int bufferSize = DEFAULT_BUFFER_SIZE) : this(music.Id, music.Name, music.ChannelId, bufferSize) { }
public MusicStreamProvider(Music music) : this(music, DEFAULT_BUFFER_SIZE) { }