public ActionResult Post([FromBody] Song song) { if (_songGetByIdService.GetItemById(song.SongId) != null) { return(this.StatusCode((int)HttpStatusCode.Conflict)); } _songAddService.AddItem(song); return(this.Ok()); }
public void AddItemTest() { Song _song = new Song(); _song.SongId = 0; _song.AlbumId = 0; _song.SongTitle = "In The End"; var sRepo = new Mock <ISRepo>(); sRepo.Setup(x => x.Add(_song)).Returns(_song.SongId); var songAddService = new SongAddService(sRepo.Object); Assert.AreEqual(songAddService.AddItem(_song), _song.SongId); }