public ApiProduct Post([FromBody] ApiProduct apiproduct) { var product = Mapper.Map <ApiProduct, Product>(apiproduct, new Product(true)); product.ArtistId = apiproduct.Artist.Href.ToId(); if (product.IsValid) { ArtContext.Products.Insert(product); apiproduct.Href = product.Id.ToProductHref(); return(apiproduct); } return(null); }
public ApiProduct Put(int?id, [FromBody] ApiProduct apiproduct) { var product = Mapper.Map <ApiProduct, Product>(apiproduct); product.ArtistId = apiproduct.Artist.Href.ToId(); if (product.IsValid) { ArtContext.Products.Update(product); return(apiproduct); } return(null); }