public SongModel GetById(string id) { var song = _songRepository.GetById(id); if (song == null) { throw new NotFoundException(Messages.InvalidSongId); } var songModel = SongMapper.ToSongModel(song); return(songModel); }
public IActionResult GetById(int id) { var song = _songRepository.GetById(id); if (!_songRepository.IsExistingId(id)) { return(NotFound("No record found matching this request")); } else { return(Ok(song)); } }
public ActionResult Details(int?id) { if (!id.HasValue) { return(RedirectToAction("Index")); } var song = _songRepository.GetById(id.Value); if (song == null) { return(RedirectToAction("Index")); } return(View(song)); }
public async Task <OperationResult <SongDTO> > Delete(int id) { var song = await songRepository.GetById(id); if (song == null) { return(OperationResult <SongDTO> .CreateNonSuccessResult("No song with the given id was found")); } await songRepository.Delete(song); return(OperationResult <SongDTO> .CreateSuccessResult()); }
public void Details_Model_Is_Expected_Model() { var expectedId = 2; var expectedModel = new Song(); repo.GetById(expectedId).Returns(expectedModel); var result = sut.Details(expectedId); var model = (Song)result.Model; Assert.Equal(expectedModel, model); }
public Song GetSongById(string songId) { Guid.TryParse(songId, out Guid guid); var song = songRepository?.GetById(guid); if (song == null) { throw new Exception(); } return(song); }
public void Index_Sets_Model_To_Correct_Song_List() { var expectedId = 2; var expectedModel = new Song(); songRepo.GetById(expectedId).Returns(expectedModel); var result = underTest.Details(expectedId); var model = (Song)result.Model; Assert.Equal(expectedModel, model); }
public async Task <SignalRMessage> ExecuteAsync(StartSongCommand command, SignalRMessage previousResult) { var song = await _songRepository.GetById(command.SongId); if (song == null) { return(null); } song.Finished = true; await _songRepository.Update(song); var user = await _userRepository.GetById(song.AddedByUser); var currentSong = await _currentSongRepository.FirstOrDefault(); if (currentSong != null) { await _currentSongRepository.Remove(currentSong.Id); } var actualCurrentSong = new CurrentSong { AddedAt = song.AddedAt, AddedByUser = song.AddedByUser, Author = song.Author, Description = song.Description, Duration = song.Duration, Finished = false, Id = Guid.NewGuid(), NoAuthor = song.NoAuthor, NoDescription = song.NoDescription, SongId = song.Id, StartedAt = DateTimeOffset.UtcNow, Thumbnail = song.Thumbnail, Title = song.Title, Url = song.Url, ViewCount = song.ViewCount, UserName = user.UserName }; await _currentSongRepository.Add(actualCurrentSong); return(new SignalRMessage { Arguments = new object[] { actualCurrentSong }, GroupName = null, Target = "startSongCommandNotification", }); }
public ActionResult GetSongs(string id) { var playlist = cachedPlRepo.GetById(new ObjectId(id)); selectedPlaylist = playlist.PlaylistName; var model = new PlaylistViewModel() { Songs = new List <SongViewModel>() }; foreach (var s in playlist.Songs) { var album = new Album(); var dbSong = songsRepo.GetById(s); var artist = new Artist(); string artistLink = "javascript:void(0)"; string albumlink = artistLink; if (playlist.GetType() == typeof(Playlist)) { album = albumService.GetAlbumById(dbSong.Album); artist = artistService.GetArtistById(album.ArtistName); albumlink = Url.Action("Album", "Artist", new { @id = album.Id.ToString() }); artistLink = Url.Action("Index", "Artist", new { name = artist.Id.ToString() }); } else { album.AlbumName = dbSong.Album; artist.ArtistName = dbSong.Artist; } var song = new SongViewModel() { Name = dbSong.Name, Album = new AlbumLink() { Name = album.AlbumName, Link = albumlink }, Artist = new ArtistLink() { Name = artist.ArtistName, Link = artistLink }, Likes = dbSong.Likes.ToString(), SongId = dbSong.SongId.ToString(), songRef = dbSong.songRef }; model.Songs.Add(song); } return(Json(model.Songs, JsonRequestBehavior.AllowGet)); }
public SongVM Get(ObjectId id) { try { var result = _songRepository.GetById(id); SongVM user = new SongVM() { Id = result.Id, DisplayName = result.DisplayName, ArtistId = result.ArtistId, AlbumId = result.AlbumId }; return(user); } catch { throw new HttpResponseException(HttpStatusCode.BadRequest); } }
public async Task <SignalRMessage> ExecuteAsync(FinishSongCommand command, SignalRMessage previousResult) { var currentSong = await _currentSongRepository.FirstOrDefault(); if (currentSong == null) { return(null); } var song = await _songRepository.GetById(currentSong.SongId); song.Finished = true; await _songRepository.Update(song); await _currentSongRepository.Remove(currentSong.Id); return(new SignalRMessage { Arguments = new object[] { currentSong }, GroupName = null, Target = "finishSongCommandNotification", }); }
public ViewResult Details(int id) { var model = songRepository.GetById(id); return(View(model)); }
public ViewResult Details(int id) { var model = repo.GetById(id); return(View(model)); }
public GetSongByIdQuery GetById(Guid id) { return(_songRepository.GetById(id)); }
public Song Get(ObjectId id) { return(_songRepository.GetById(id)); }
public ViewResult Details(int id) { Song model = songRepo.GetById(id); return(View(model)); }
// // GET: /Song/Details/5 public ViewResult Details(int id) { return(View(songRepository.GetById(id))); }
private async Task <bool> ValidateSongId(Guid songId, CancellationToken cancellationToken) { var song = await _songRepository.GetById(songId); return(song != null && !song.Finished); }
public SongDto GetSongById(int id) { var song = _songRepository.GetById(id); return(new SongDto(song)); }