// POST: api/Albums public IHttpActionResult Post([FromBody]AlbumsRequestModel value) { var album = new Album { Id = value.Id, Producer = value.Producer, Title = value.Title, Year = value.Year }; db.Albums.Add(album); db.SaveChanges(); return this.Ok(string.Format("{0} was added to Albums", album.Title)); }
public IHttpActionResult Create(AlbumRequestModel album) { if (!this.ModelState.IsValid) { return BadRequest(this.ModelState); } var newAlbum = new Album { Title = album.Title, Year = album.Year, Producer = album.Producer }; this.data.Albums.Add(newAlbum); this.data.Albums.SaveChanges(); return Ok(new { Album = album, Id = newAlbum.Id }); }