public IActionResult PutProduct(int key, [FromBody] Models.Sample.Product newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (newItem == null || (newItem.Id != key))
                {
                    return(BadRequest());
                }

                this.OnProductUpdated(newItem);
                this.context.Products.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.Products.Where(i => i.Id == key);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
        public IActionResult Post([FromBody] Models.Sample.Product item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (item == null)
                {
                    return(BadRequest());
                }

                this.OnProductCreated(item);
                this.context.Products.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/Sample/Products/{item.Id}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
        public IActionResult PutProduct(int key, [FromBody] Models.Sample.Product newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (newItem == null || (newItem.Id != key))
                {
                    return(BadRequest());
                }

                this.OnProductUpdated(newItem);
                this.context.Products.Update(newItem);
                this.context.SaveChanges();

                return(new NoContentResult());
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
 partial void OnProductUpdated(Models.Sample.Product item);
 partial void OnProductDeleted(Models.Sample.Product item);