This repository has been archived by the owner on Jan 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
GetCustomerAgreements.cs
51 lines (44 loc) · 1.8 KB
/
GetCustomerAgreements.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// <copyright file="GetCustomerAgreements.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
namespace Microsoft.Store.PartnerCenter.Samples.Agreements
{
using System;
using System.Linq;
using Models;
using Models.Agreements;
/// <summary>
/// Showcases the retrieval of customer agreements.
/// </summary>
public class GetCustomerAgreements : BasePartnerScenario
{
/// <summary>
/// Initializes a new instance of the <see cref="GetCustomerAgreements"/> class.
/// </summary>
/// <param name="context">The scenario context.</param>
public GetCustomerAgreements(IScenarioContext context) : base("Get agreements for a customer.", context)
{
}
/// <summary>
/// Executes the get customer agreements scenario.
/// </summary>
protected override void RunScenario()
{
var partnerOperations = this.Context.UserPartnerOperations;
string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get agreement for");
this.Context.ConsoleHelper.StartProgress("Retrieving agreements of the customer");
ResourceCollection<Agreement> customerAgreements = partnerOperations.Customers.ById(selectedCustomerId)
.Agreements.Get();
this.Context.ConsoleHelper.StopProgress();
if (!customerAgreements.Items.Any())
{
Console.WriteLine("No agreements found for the given customer.");
}
else
{
this.Context.ConsoleHelper.WriteObject(customerAgreements, "Customer agreements:");
}
}
}
}