public void DeleteSongTest() { Mock <ISongRepository> songRepositoryMock = new Mock <ISongRepository>(); var songId1 = songs.Where(s => s.Id == 1).ToList(); songRepositoryMock.Setup(s => s.Delete(It.IsAny <Song>())).Callback <Song>(s => songs.Remove(s)); songRepositoryMock.Setup(s => s.FindOne(It.IsAny <long>())).Returns <long>(l => songs.Where(s => s.Id == l).SingleOrDefault()); ISongService songService = new SongService(songRepositoryMock.Object, null); songService.Delete(1); Assert.AreEqual(null, songService.FindById(1)); songService.Delete(1); }
public void rptSongs_ItemCommand(object source, RepeaterCommandEventArgs e) { var setSongService = new SetSongService(Ioc.GetInstance <ISetSongRepository>()); var setSong = setSongService.GetSetSong(new Guid(e.CommandArgument.ToString())); if (e.CommandName.ToLower() == "fix") { txtSongName.Text = setSong.SongName; hdnSetSongIdToFix.Value = setSong.SetSongId.ToString(); } else if (e.CommandName.ToLower() == "delete") { ///TEST THIS SECTION var songService = new SongService(Ioc.GetInstance <ISongRepository>()); var song = songService.GetSong(setSong.SongId.Value); using (IUnitOfWork uow = UnitOfWork.Begin()) { setSongService.Delete(setSong); if (song != null) { songService.Delete(song); } uow.Commit(); } var setsongs = setSongService.GetAllSetSongs().Where(x => x.SongName.Contains(txtSearchSongName.Text)); rptSongs.DataSource = setsongs; rptSongs.DataBind(); } }
public IActionResult Delete([FromRoute] int id) { if (songService.Delete(id)) { return(NoContent()); } return(BadRequest()); }
public async Task <IActionResult> DeleteSong([FromRoute] long id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var song = await _songService.Delete(id); if (song == null) { return(NotFound()); } else { return(Ok()); } }
// Métodos crud static void ThirdExample() { var songService = new SongService(); var newEntry = new Song { Description = "Excelente canción de Metallica", Title = "Nothing Else Matter", Duration = TimeSpan.FromSeconds(350), AlbumId = 2 }; songService.Add(newEntry); newEntry.Title = "One"; songService.Update(newEntry); songService.Delete(newEntry.Id); }
public Song Delete(string id) { return(songService.Delete(id)); }
public void Delete(int id, string notes = "") { service.Delete(id, notes ?? string.Empty); }