public IHttpActionResult GetOption(Guid productId, Guid id) { ProductOptionsQuery query = new ProductOptionsQuery(); ProductOption option = query.GetOption(id); if (option == null) { return(NotFound()); } return(Ok(option)); }
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()); }
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(); } }
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()); }
public IEnumerable <ProductOption> GetOptions(Guid productId) { ProductOptionsQuery query = new ProductOptionsQuery(); return(query.GetAll(productId)); }