// PUT api/song/5 public HttpResponseMessage Put(Song song) { _unitOfWork.Songs.Update(song); _unitOfWork.Commit(); return new HttpResponseMessage(HttpStatusCode.NoContent); }
// POST api/song public HttpResponseMessage Post(Song song) { song.Band = _unitOfWork.Bands.GetById(song.Band.Id); _unitOfWork.Songs.Add(song); _unitOfWork.Commit(); var response = Request.CreateResponse(HttpStatusCode.Created, song); response.Headers.Location = new Uri(Url.Link(WebApiConfig.ControllerAndId, new { id = song.Id })); return response; }