Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }