/// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="adGroupId">Id of the ad group to which criteria are
    /// added.</param>
    public void Run(AdWordsUser user, long adGroupId) {
      // Get the AdGroupCriterionService.
      AdGroupCriterionService adGroupCriterionService =
          (AdGroupCriterionService) user.GetService(AdWordsService.v201509.AdGroupCriterionService);

      // Create biddable ad group criterion for gender
      Gender genderTarget = new Gender();
      // Criterion Id for male. The IDs can be found here
      // https://developers.google.com/adwords/api/docs/appendix/genders
      genderTarget.id = 10;

      BiddableAdGroupCriterion genderBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
      genderBiddableAdGroupCriterion.adGroupId = adGroupId;
      genderBiddableAdGroupCriterion.criterion = genderTarget;

      // Create negative ad group criterion for age range
      AgeRange ageRangeNegative = new AgeRange();
      // Criterion Id for age 18 to 24. The IDs can be found here
      // https://developers.google.com/adwords/api/docs/appendix/ages

      ageRangeNegative.id = 503001;
      NegativeAdGroupCriterion ageRangeNegativeAdGroupCriterion = new NegativeAdGroupCriterion();
      ageRangeNegativeAdGroupCriterion.adGroupId = adGroupId;
      ageRangeNegativeAdGroupCriterion.criterion = ageRangeNegative;

      // Create operations.
      AdGroupCriterionOperation genderBiddableAdGroupCriterionOperation =
          new AdGroupCriterionOperation();
      genderBiddableAdGroupCriterionOperation.operand = genderBiddableAdGroupCriterion;
      [email protected] = Operator.ADD;

      AdGroupCriterionOperation ageRangeNegativeAdGroupCriterionOperation =
          new AdGroupCriterionOperation();
      ageRangeNegativeAdGroupCriterionOperation.operand = ageRangeNegativeAdGroupCriterion;
      [email protected] = Operator.ADD;

      AdGroupCriterionOperation[] operations = new AdGroupCriterionOperation[] {
          genderBiddableAdGroupCriterionOperation, ageRangeNegativeAdGroupCriterionOperation};

      try {
        // Add ad group criteria.
        AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);

        // Display ad group criteria.
        if (result != null && result.value != null) {
          foreach (AdGroupCriterion adGroupCriterionResult in result.value) {
            Console.WriteLine("Ad group criterion with ad group id \"{0}\", criterion id " +
                "\"{1}\", and type \"{2}\" was added.", adGroupCriterionResult.adGroupId,
                adGroupCriterionResult.criterion.id,
                adGroupCriterionResult.criterion.CriterionType);
          }
        } else {
          Console.WriteLine("No ad group criteria were added.");
        }
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to create ad group criteria.", e);
      }
    }
 public double CalculateYearlyPrice(AgeRange AgeRange, TypeOfVehicle TypeOfVehicle, PolicyType PolicyType)
 {
     double price = 0;
     this.ageRange = AgeRange;
     this.typeOfVehicle = TypeOfVehicle;
     this.policyType = PolicyType;
     lengthModfier = 3;
     price = CalculatePrice();
     return price;
 }
 /// <summary>
 /// controller method calls database modifcation methods as well as controls the system message
 /// </summary>
 public string ModifyPolicy(int id, string Name, TypeOfVehicle TypeOfVehicle, PolicyType PolicyType, AgeRange AgeRange)
 {
     string returnMessage = "";
     DataBaseController controller = new DataBaseController();
     policy.Name = Name;
     policy.TypeOfVechile = TypeOfVehicle;
     policy.PolicyType = PolicyType;
     policy.AgeRange = AgeRange;
     returnMessage = controller.ModifyPolicy(policy, id);
     return returnMessage;
 }
 /// <summary>
 /// controller method calls database write new policy methods as well as controls the system messages
 /// </summary>
 public string CreateNewPolicy(string Name, TypeOfVehicle TypeOfVehicle, PolicyType PolicyType, AgeRange AgeRange)
 {
     string returnMessage = "";
     DataBaseController controller = new DataBaseController();
     policy.Name = Name;
     policy.TypeOfVechile = TypeOfVehicle;
     policy.PolicyType = PolicyType;
     policy.AgeRange = AgeRange;
     policy.CalculatePrice();
     returnMessage = controller.CreatePolicy(policy);
     return returnMessage;
 }
        //---------------------------------------------------------------------

        /// <summary>
        /// Does the range overlap another range?
        /// </summary>
        public bool Overlaps(AgeRange other)
        {
            return Contains(other.Start) || other.Contains(start);
        }