public AudioBookModel CreateAudioBook(AudioBookModel newModel) { // validate first if (State.Authors.All(c => c.Id != newModel.AuthorId)) { return(null); } if (newModel.Tags.Any(tag => State.Tags.All(c => c.Id != tag))) { return(null); } // override the given id anyway (force recreate) newModel.Id = Guid.NewGuid(); // add new model to state State.AudioBooks.Add(newModel); // state persistance State.SaveChanges(); // returns model with new guid return(newModel); }
public async Task <IActionResult> Post([FromBody] AudioBookModel model) { return(this.Ok(model)); }