예제 #1
0
        public IHttpActionResult GetByProductId(Guid productId)
        {
            var productOptions = _productOptionRepository.GetByProductId(productId);

            if (productOptions == null || !productOptions.Any())
            {
                return(StatusCode(HttpStatusCode.NotFound));
            }
            return(Ok(productOptions));
        }
예제 #2
0
        public void Delete(Guid productId)
        {
            var options = _productOptionRepository.GetByProductId(productId);

            foreach (var option in options.Items)
            {
                _productOptionRepository.Delete(option.Id);
            }

            using (var conn = NewConnection())
            {
                var cmd = conn.CreateCommand();
                cmd.CommandText = $"DELETE FROM Product WHERE Id = @Id";
                cmd.Parameters.AddWithValue("@Id", productId);

                conn.Open();
                cmd.ExecuteNonQuery();
            }
        }
예제 #3
0
 public ProductOptions GetOptions(Guid productId)
 {
     return(_productOptionRepository.GetByProductId(productId));
 }