コード例 #1
0
        public Product Post(int id, Product product)
        {
            Trace.WriteLine(id);
              Trace.WriteLine(product);

              _repository.Save(product);

              return product;
        }
コード例 #2
0
        public Product Save(Product product)
        {
            using (var conn = GetConnection())
            {
              var transaction = conn.BeginTransaction();

              conn.Execute("UPDATE Products SET Caption = @caption, BrandId = @brandId, ProductTypeId = @productTypeId, StyleId = @styleId WHERE Id = @id",
            new { caption = product.ProductName, brandId = product.BrandId, productTypeId = product.ProductTypeId, styleId = product.StyleId, id = product.Id},
            transaction);

              transaction.Commit();
            }
            return GetProduct(product.Id);
        }