Beispiel #1
0
        public IHttpActionResult GetOption(Guid productId, Guid id)
        {
            ProductOptionsQuery query  = new ProductOptionsQuery();
            ProductOption       option = query.GetOption(id);

            if (option == null)
            {
                return(NotFound());
            }

            return(Ok(option));
        }
Beispiel #2
0
        public IHttpActionResult DeleteOption(Guid id)
        {
            ProductOptionsQuery query  = new ProductOptionsQuery();
            ProductOption       option = query.GetOption(id);

            if (option == null)
            {
                return(NotFound());
            }

            new DeleteProductOption(option).Call();

            return(Ok());
        }
Beispiel #3
0
        public void Call()
        {
            ProductOptionsQuery query = new ProductOptionsQuery();

            foreach (ProductOption option in query.GetAll(Product.Id))
            {
                new DeleteProductOption(option).Call();
            }

            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "delete from product where id = '@id'";
                command.Parameters.AddWithValue("@id", Product.Id);

                new RunQuery(command).Execute();
            }
        }
Beispiel #4
0
        public IHttpActionResult UpdateOption(Guid id, [FromBody] ProductOption option)
        {
            if (option == null || option.Id != id)
            {
                return(BadRequest());
            }

            ProductOptionsQuery query          = new ProductOptionsQuery();
            ProductOption       originalOption = query.GetOption(id);

            if (originalOption == null)
            {
                return(NotFound());
            }

            new UpdateProductOption(id, option).Call();

            return(Ok());
        }
Beispiel #5
0
        public IEnumerable <ProductOption> GetOptions(Guid productId)
        {
            ProductOptionsQuery query = new ProductOptionsQuery();

            return(query.GetAll(productId));
        }