Last active
April 1, 2016 18:26
-
-
Save Mozu-CS/60b602609c1708cd1b6c to your computer and use it in GitHub Desktop.
Basic C# Mozu example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<startup> | |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | |
</startup> | |
<appSettings> | |
<add key="TenantId" value="tenant_id" /> | |
<add key="SiteId" value="site_id" /> | |
<add key="ApplicationId" value="app_key" /> | |
<add key="SharedSecret" value="shared_secret" /> | |
</appSettings> | |
<runtime> | |
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |
<dependentAssembly> | |
<assemblyIdentity version="4.5.0.0" name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> | |
</dependentAssembly> | |
<dependentAssembly> | |
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-1.2.15.0" newVersion="1.2.15.0" /> | |
</dependentAssembly> | |
</assemblyBinding> | |
</runtime> | |
</configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Mozu.Api.ToolKit; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace AMSXBGCONSOLE | |
{ | |
class Bootstrapper : AbstractBootstrapper | |
{ | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Configuration; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Autofac; | |
using Mozu.Api; | |
using Mozu.Api.ToolKit.Config; | |
namespace AMSXBGCONSOLE | |
{ | |
class Program | |
{ | |
private static IApiContext _apiContext { get; set; } | |
private static IContainer _container { get; set; } | |
static void Main(string[] args) | |
{ | |
var apiContext = Program.GenerateApicontext(); | |
var customerAccountResource = new Mozu.Api.Resources.Commerce.Customer.CustomerAccountResource(apiContext); | |
var customerAccountCollection = customerAccountResource.GetAccountsAsync(pageSize: 200).Result; | |
Console.WriteLine(customerAccountCollection.TotalCount); | |
Console.ReadLine(); | |
} | |
private static ApiContext GenerateApicontext() | |
{ | |
_container = new Bootstrapper().Bootstrap().Container; | |
var appSetting = _container.Resolve<IAppSetting>(); | |
var tenantId = int.Parse(appSetting.Settings["TenantId"].ToString()); | |
var siteId = int.Parse(appSetting.Settings["SiteId"].ToString()); | |
_apiContext = new ApiContext(siteId: siteId, tenantId: tenantId); | |
return _apiContext; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment