public IHttpActionResult PutProduct(int id, NewProductDTO updatedProduct) { if (updatedProduct == null) return this.BadRequest("no product details were sent"); var product = _products.FirstOrDefault((p) => p.Id == id); if (product == null) { return NotFound(); } product.Name = updatedProduct.Name; product.Category = updatedProduct.Category; product.Price = updatedProduct.Price; product.LastUpdate = DateTime.UtcNow; return Ok(); }
public IHttpActionResult PostProduct(NewProductDTO product) { if (product == null) return this.BadRequest("no product details were sent"); _products.Add(new Product() { Id = GenerateNewId(), Category = product.Category, Name = product.Name, Price = product.Price, LastUpdate = DateTime.UtcNow }); return Ok(); }