public async Task<IHttpActionResult> Put([FromODataUri] string key, Product model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (key != model.Id)
            {
                return BadRequest();
            }

            var product = await db.Products.FindAsync(model.Id);
            if (product == null)
            {
                return NotFound();
            }
           
            try
            {
                product.Modify(model, db);
                //db.Entry(product).State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return BadRequest(ex.Message);
            }

            return Updated(model);
        }
        public void Modify(Product model, ApplicationDbContext db)
        {
            base.Modify(model, db);

            CategoryId = model.CategoryId;
            Price = model.Price;
            ShelfLife = model.ShelfLife;
            CoverUrl = model.CoverUrl;
            Sales = model.Sales;
        }
        public async Task<IHttpActionResult> Post(Product model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                model.Create(db);
                db.Products.Add(model);

                await db.SaveChangesAsync();

                return Ok(model);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("PostError", ex.Message);

                return BadRequest(ModelState);
            }
        }