public HttpResponseMessage PostProduct(ProductModel product) { try { if (product.Id == 0) { var service = new ProductTransactionService(); service.CreateProduct(product); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { var service = new DbService(); service.UpdateProduct(product); return(new HttpResponseMessage(HttpStatusCode.OK)); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(ex.Message) }); } }
public HttpResponseMessage DeleteProduct(int Id) { try { var service = new ProductTransactionService(); service.DeleteProduct(Id); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(ex.Message) }); } }