public HttpResponseMessage AddProduct(Product product) { var prod = appSrv.GetAllProducts(x => x.ProductID == product.ProductID) .SingleOrDefault(); if (prod != null) { prod.ProductName = product.ProductName; prod.CategoryID = product.CategoryID; } var result = appSrv.AddProduct(prod ?? product); if (result > 0) { return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.ExpectationFailed)); }