Esempio n. 1
0
        public async Task <string> Delete(int id)
        {
            var track   = _multiSourcePlaylistRepository.GetTrack(id);
            var address = track.Address;
            var type    = track.Type;

            _multiSourcePlaylistRepository.DeleteTrack(id);
            var claimsIdentity = User.Identity as ClaimsIdentity;
            var userId         = Convert.ToInt64(claimsIdentity.Claims.FirstOrDefault(claim => claim.Type == "Id").Value);
            var user           = _multiSourcePlaylistRepository.GetUser(userId);
            var mp3type        = 3;
            var mp3type2       = 5;

            if (type == mp3type && !_multiSourcePlaylistRepository.GetTracksByTypeAndAddress(mp3type, address, userId).Any())
            {
                if (!await CloudHelper.RemoveFileFromCloudFile(
                        _configuration["Production:StorageConnectionString"],
                        user.FileFolder,
                        address))
                {
                    return("FAILED");
                }
            }
            else if (type == mp3type2 && !_multiSourcePlaylistRepository.GetTracksByTypeAndAddress(mp3type2, address, userId).Any())
            {
                if (!await CloudHelper.RemoveFileFromCloudBlob(
                        _configuration["Production:StorageConnectionString"],
                        user.FileFolder,
                        address))
                {
                    return("FAILED");
                }
            }
            return("SUCCESS");
        }