示例#1
0
        public async Task <List <MusicInfo> > DeleteMusic(int id)
        {
            User user = await db.Users.FindAsync(UserId);

            Music music = await db.Musics.FindAsync(id);

            List <MusicInfo> res = new List <MusicInfo>();

            if (music != null)
            {
                try
                {
                    await cloud.DeleteFile("", music.MusicFileName);

                    if (music.MusicImageName != "default.png")
                    {
                        await cloud.DeleteFile("", music.MusicImageName);
                    }
                    db.Musics.Remove(music);
                    await db.SaveChangesAsync();
                }
                catch
                {
                }
            }
            return(await GetMusicListByUserId(UserId));
        }