示例#1
0
 private static Song CreateSong(Song song)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         SongService songService = new SongService(context);
         return(songService.Create(song));
     }
 }
示例#2
0
 public IActionResult Create([FromBody] SongDto song)
 {
     if (!song.IsValid())
     {
         return(BadRequest());
     }
     if (songService.Create(song))
     {
         return(NoContent());
     }
     return(BadRequest());
 }
示例#3
0
 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"
         });
     }
 }
示例#4
0
 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));
 }