Ejemplo n.º 1
0
        public ViewResult NewSong()
        {
            Song newSong = new Song {
                Title = Request.Form["Title"], Artist = Request.Form["Artist"]
            };

            repository.AddSong(newSong);
            repository.SaveContext();

            return(View());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> PostSong(Song song)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var addedSong = await SongRepository.AddSong(song);

                    return(Ok(new ApiOKResponse(addedSong)));
                }
                catch (DbUpdateException)
                {
                    return(Conflict(new ApiResponse(409, "There is already a Song with that name.")));
                }
            }
            else
            {
                return(BadRequest(new ApiBadRequestResponse(ModelState)));
            }
        }
Ejemplo n.º 3
0
        public async Task <SongAddDTO> AddSong(SongAddDTO song)
        {
            try
            {
                // voor DTO
                Song newSong = _mapper.Map <Song>(song);
                newSong.SongId = Guid.NewGuid();

                foreach (var artistId in song.ArtistIds)
                {
                    Artist artist = await GetArtistByArtistId(artistId);

                    if (artist != null)
                    {
                        await _songRepository.AddSongArtist(new SongArtist()
                        {
                            SongArtistId = Guid.NewGuid(),
                            SongId       = newSong.SongId,
                            ArtistId     = artistId,
                        });
                    }
                }

                Recordlabel recordlabel = await GetRecordlabelById(song.RecordLabelId);

                if (recordlabel != null)
                {
                    newSong.LabelId = recordlabel.RecordLabelId;
                }

                await _songRepository.AddSong(newSong);

                return(song);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        private async Task ProcesameLaSong(string songPath, Band band, Style style)
        {
            try
            {
                if (!songPath.ToLower().EndsWith(".mid"))
                {
                    return;
                }
                try
                {
                    var lelo = MidiFile.Read(songPath, null);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, $"Song {songPath} esta podrida");
                    return;
                }

                var originalMidiBase64encoded = FileSystemUtils.GetBase64encodedFile(songPath);
                originalMidiBase64encoded = MidiProcessing.NormalizeTicksPerQuarterNote(originalMidiBase64encoded);

                Song song = new Song()
                {
                    Name  = Path.GetFileName(songPath),
                    Band  = band,
                    Style = style,
                    OriginalMidiBase64Encoded = originalMidiBase64encoded,
                };
                song = MidiProcessing.ComputeSongStats(song);
                song.TimeSignature = await SongRepository.GetTimeSignature(song.TimeSignature);


                song.NormalizeSong();
                song = await SongRepository.AddSong(song);

                song.FindSongPatterns();

                foreach (var oc in song.Versions[0].Occurrences)
                {
                    var pattern = oc.Pattern;
                    var patito  = await SongRepository.GetPatternByStringAndTypeAsync(pattern.AsString, pattern.PatternTypeId);

                    if (patito == null)
                    {
                        patito = SongRepository.AddPatternAsync(pattern);
                    }
                    oc.Pattern       = patito;
                    oc.PatternId     = patito.Id;
                    oc.SongVersionId = song.Versions[0].Id;
                }
                await SongRepository.UpdateSong(song);


                var outputPath = Path.Combine(@"C:\music\procesados", song.Name);
                var bytes      = Convert.FromBase64String(song.ProcessedMidiBase64Encoded);
                System.IO.File.WriteAllBytes(outputPath, bytes);
            }
            catch (Exception sorete)
            {
            }
        }
Ejemplo n.º 5
0
 public ActionResult AddSong(Song song)
 {
     songRepository.AddSong(song);
     return(RedirectToAction("Details/" + song.AlbumId, "Album"));
 }
Ejemplo n.º 6
0
        public SongDto AddSong(SongDto songDto)
        {
            Song song = Mapper.Map(songDto);

            return(Mapper.Map(SongRepository.AddSong(song)));
        }