ConstructorIO.ConstructorIOAPI.RemoveAsync C# (CSharp) Method

RemoveAsync() public method

Removes an item from your autocomplete.
public RemoveAsync ( ListItem ItemToRemove ) : Task
ItemToRemove ListItem The item to remove.
return Task
        public async Task<bool> RemoveAsync(ListItem ItemToRemove)
        {
            var removeRequest = new ConstructorIORequest(APIRequestType.V1_Item, "DELETE");

            Util.Merge(ItemToRemove.GetAsRemoveHash(), removeRequest.RequestBody);

            var removeResponse = await Requestor.MakeRequest(removeRequest);
            return removeResponse.Item1;
        }

Usage Example

        private async void btnProcess_Click(object sender, EventArgs e)
        {
            pictureBoxLoading.Visible = true;

            try
            {
                bool bResult = false;

                m_constructorClient = new ConstructorIOAPI(txtAPI.Text, txtKey.Text);
                ListItem createdItem = GetListItem();

                switch (m_sActionValue)
                {
                    case "Add":
                        bResult = await m_constructorClient.AddAsync(createdItem);
                        break;
                    case "Modify ( name of item )":
                        bResult = await m_constructorClient.ModifyAsync(createdItem);
                        break;
                    case "Delete":
                        bResult = await m_constructorClient.RemoveAsync(createdItem);
                        break;
                }

                if(bResult)
                {
                    MessageBox.Show("Success.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            pictureBoxLoading.Visible = false;
        }