コード例 #1
0
 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)
         });
     }
 }
コード例 #2
0
 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)
         });
     }
 }