public IHttpActionResult Post([FromBody]GenreDataModel model) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } var genre = new Genre { Name = model.Name }; this.data.Genres.Add(genre); this.data.Savechanges(); return this.Created(this.Url.ToString(), genre); }
public IHttpActionResult Post([FromBody]GenreRequestModel model) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } var entity = new Genre { Name = model.Name }; this.context.AddEntity(entity); this.context.Save(); return this.Created(this.Url.ToString(), entity); }