private static Song CreateSong(Song song) { using (ApplicationDbContext context = new ApplicationDbContext()) { SongService songService = new SongService(context); return(songService.Create(song)); } }
public IActionResult Create([FromBody] SongDto song) { if (!song.IsValid()) { return(BadRequest()); } if (songService.Create(song)) { return(NoContent()); } return(BadRequest()); }
private static void AddSong(Album album) { using (ApplicationDbContext context = new ApplicationDbContext()) { SongService songService = new SongService(context); songService.Create(new Song { AlbumId = album.Id, Description = "Third Song Description", Duration = TimeSpan.FromSeconds(250), Title = "Third Song Title" }); } }
public Song Post([FromBody] Song payload) { return(songService.Create(payload)); }
public ActionResult <Song> Create([FromBody] Song song) { _songService.Create(song); return(CreatedAtRoute("GetSong", new { id = song.Id.ToString() }, song)); }