public IHttpActionResult Create(Album album) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } db.Albums.Add(album); db.SaveChanges(); return this.Ok(); }
// POST: api/Album public IHttpActionResult Post(AlbumRequestModel albumInfo) { if (albumInfo == null) { return this.BadRequest(); } var albumToAdd = new Album { Title = albumInfo.Title, Year = albumInfo.Year, }; albumToAdd.Producer = this.producerData.All().FirstOrDefault(p => p.Name == albumInfo.Producer); this.albumData.Add(albumToAdd); this.albumData.SaveChanges(); return this.Ok(); }