Beispiel #1
0
        /// <summary>
        /// Adds the price asset to the customer account, allowing it to serve all campaigns under
        /// the account.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The customer ID for which the call is made.</param>
        /// <param name="priceAssetResourceName">The price asset resource name for which the call is
        /// made.</param>
        private void AddExtensionToAccount(GoogleAdsClient client, long customerId,
                                           string priceAssetResourceName)
        {
            CustomerAsset customerAsset = new CustomerAsset
            {
                Asset     = priceAssetResourceName,
                FieldType = AssetFieldTypeEnum.Types.AssetFieldType.Price,
            };

            // Issues the create request to add the callout.
            CustomerAssetServiceClient customerAssetServiceClient =
                client.GetService(Services.V10.CustomerAssetService);
            CustomerAssetOperation operation = new CustomerAssetOperation
            {
                Create = customerAsset,
            };

            CustomerAssetServiceClient assetClient =
                client.GetService(Services.V10.CustomerAssetService);
            MutateCustomerAssetsResponse response =
                assetClient.MutateCustomerAssets(customerId.ToString(), new[] { operation });

            string resourceName = response.Results[0].ResourceName;

            Console.WriteLine($"Created customer asset with resource name '{resourceName}'.");
        }
Beispiel #2
0
 /// <summary>Snippet for GetCustomerAsset</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetCustomerAsset()
 {
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER_ID]/customerAssets/[ASSET_ID]~[FIELD_TYPE]";
     // Make the request
     CustomerAsset response = customerAssetServiceClient.GetCustomerAsset(resourceName);
 }
 /// <summary>Snippet for GetCustomerAsset</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetCustomerAssetResourceNames()
 {
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     CustomerAssetName resourceName = CustomerAssetName.FromCustomerAssetFieldType("[CUSTOMER_ID]", "[ASSET_ID]", "[FIELD_TYPE]");
     // Make the request
     CustomerAsset response = customerAssetServiceClient.GetCustomerAsset(resourceName);
 }
Beispiel #4
0
        public async Task <bool> AssignAsset(CustomerAsset customerAsset)
        {
            bool status = false;

            if (customerAsset != null)
            {
                status = await _customerDAL.AssignAsset(customerAsset);
            }

            return(status);
        }
Beispiel #5
0
        /// <summary>Snippet for GetCustomerAssetAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetCustomerAssetRequestObjectAsync()
        {
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetCustomerAssetRequest request = new GetCustomerAssetRequest
            {
                ResourceNameAsCustomerAssetName = CustomerAssetName.FromCustomerAssetFieldType("[CUSTOMER_ID]", "[ASSET_ID]", "[FIELD_TYPE]"),
            };
            // Make the request
            CustomerAsset response = await customerAssetServiceClient.GetCustomerAssetAsync(request);
        }
Beispiel #6
0
        /// <summary>Snippet for GetCustomerAssetAsync</summary>
        public async Task GetCustomerAssetAsync()
        {
            // Snippet: GetCustomerAssetAsync(string, CallSettings)
            // Additional: GetCustomerAssetAsync(string, CancellationToken)
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/customerAssets/[ASSET_ID]~[FIELD_TYPE]";
            // Make the request
            CustomerAsset response = await customerAssetServiceClient.GetCustomerAssetAsync(resourceName);

            // End snippet
        }
Beispiel #7
0
 /// <summary>Snippet for GetCustomerAsset</summary>
 public void GetCustomerAssetRequestObject()
 {
     // Snippet: GetCustomerAsset(GetCustomerAssetRequest, CallSettings)
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     GetCustomerAssetRequest request = new GetCustomerAssetRequest
     {
         ResourceNameAsCustomerAssetName = CustomerAssetName.FromCustomerAssetFieldType("[CUSTOMER_ID]", "[ASSET_ID]", "[FIELD_TYPE]"),
     };
     // Make the request
     CustomerAsset response = customerAssetServiceClient.GetCustomerAsset(request);
     // End snippet
 }
Beispiel #8
0
        /// <summary>Snippet for GetCustomerAssetAsync</summary>
        public async Task GetCustomerAssetResourceNamesAsync()
        {
            // Snippet: GetCustomerAssetAsync(CustomerAssetName, CallSettings)
            // Additional: GetCustomerAssetAsync(CustomerAssetName, CancellationToken)
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            CustomerAssetName resourceName = CustomerAssetName.FromCustomerAssetFieldType("[CUSTOMER_ID]", "[ASSET_ID]", "[FIELD_TYPE]");
            // Make the request
            CustomerAsset response = await customerAssetServiceClient.GetCustomerAssetAsync(resourceName);

            // End snippet
        }
Beispiel #9
0
        public async Task <bool> AssignAsset(CustomerAsset customerAsset)
        {
            try
            {
                if (customerAsset != null)
                {
                    int countOfCustomer = _assetDBContext.CustomerAssets.Where(x => x.CustomerId == customerAsset.CustomerId).Count();
                    if (countOfCustomer < 3)
                    {
                        await _assetDBContext.CustomerAssets.AddRangeAsync(customerAsset);

                        await _assetDBContext.SaveChangesAsync();

                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
 public Task <bool> AssignAsset(CustomerAsset customerAsset)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
        public async Task <bool> AssignAsset(CustomerAssetDTO customerAssetDTO)
        {
            CustomerAsset customerAsset = _mapper.Map <CustomerAsset>(customerAssetDTO);

            return(await _customerBLL.AssignAsset(customerAsset));
        }