Example #1
0
        public static ICommerceApi Commerce(this Site site)
        {
            var context = new ApiContext(site.GetCommerceInstanceName(), CultureInfo.GetCultureInfo(site.Culture));

            var user = new HttpContextWrapper(HttpContext.Current).Membership().GetMembershipUser();
            if (user != null)
            {
                context.Customer = new CustomerIdentity
                {
                    Email = user.UUID
                };
            }

            var apiType = "Local";
            if (site.CustomFields.ContainsKey("CommerceApiType"))
            {
                apiType = site.CustomFields["CommerceApiType"];
            }

            return ApiService.Get(apiType, context);
        }
Example #2
0
 public static ICommerceApi Get(string type, ApiContext context)
 {
     var api = EngineContext.Current.Resolve<ICommerceApi>(type);
     api.Initialize(context);
     return api;
 }