Ejemplo n.º 1
0
 private void ValidateOrder(List <eBayFBOrder> ofOrders, String OrderStatus)
 {
     foreach (var o in ofOrders)
     {
         o.FbOrder = DataMappers.MapSalesOrder(cfg, o, OrderStatus);
     }
 }
        public void DownloadOrders()
        {
            Log("Downloading Orders");
            List <ZCOrder> orders = zc.GetOrders();

            CreateOrderZenCart();
            Log("Orders Downloaded: " + orders.Count);
            if (orders.Count > 0)
            {
                List <ZCFBOrder> ofOrders = DataMappers.MapNewOrders(orders);
                ofOrders = fb.MapCustomerID(ofOrders);

                Log("Creating and Validating Customer Names.");
                ValidateCreateCustomers(ofOrders);
                Log("Validated Customers");

                /* Will need to turn-on this code, once the Create Product functionality is in place....
                 * Log("Validating Items in Fishbowl.");
                 * ValidateItems(ofOrders);
                 * Log("Items Validated");
                 */

                Log("Creating Sales Orders Data.");
                ValidateOrder(cfg, ofOrders, "10 ");
                Log("Finished Creating Sales Order Data.");

                var ret = CreateSalesOrders(ofOrders);

                Log("Result: " + String.Join(Environment.NewLine, ret));

                Log("Downloading Orders Finished");
            }
        }
        private void CreateCustomer(string customerName, ZCOrder Order)
        {
            Log("Creating Fishbowl Customer " + customerName);
            var cas      = fb.GetCountryState(Order.billing_country, Order.billing_state);
            var customer = DataMappers.MapCustomer(cfg, Order, customerName, cas);

            fb.CreateCustomer(customer);
        }
Ejemplo n.º 4
0
        public void DownloadOrders()
        {
            Log("Downloading Orders");

            OrderTypeCollection orders = new OrderTypeCollection();

            if (!String.IsNullOrEmpty(cfg.Store.SyncOrder.TestOrderID))
            {
                Log("Downloading Test Order# " + cfg.Store.SyncOrder.TestOrderID);
                orders.Add(ebc.GetTestOrder(cfg.Store.SyncOrder.TestOrderID));
            }
            else
            {
                orders = ebc.allCompletedOrders(cfg.Store.SyncOrder.LastDownloads.ToString());
            }


            Log("Orders Downloaded: " + orders.Count);
            if (orders.Count > 0)
            {
                List <eBayFBOrder> ofOrders = DataMappers.MapNewOrders(cfg, orders);

                Log("Validating Items in Fishbowl.");
                ValidateItems(ofOrders);
                Log("Items Validated");


                Log("Creating Sales Orders Data.");
                ValidateOrder(ofOrders, "20");
                Log("Finished Creating Sales Order Data.");

                Log("Validate Carriers");
                ValidateCarriers(ofOrders);
                Log("Carriers Validated");

                Log("Kit Items");
                ValidateKits(ofOrders);
                Log("Finished Kits.");

                var ret = CreateSalesOrders(ofOrders);

                Log("Result: " + String.Join(Environment.NewLine, ret));

                Log("Downloading Orders Finished");
            }
        }
Ejemplo n.º 5
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddAuthentication(options =>
            {
                options.DefaultSignInScheme       = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(cfg =>
            {
                cfg.RequireHttpsMetadata      = false;
                cfg.SaveToken                 = true;
                cfg.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidIssuer      = Configuration["token:issuer"],
                    ValidAudience    = Configuration["token:audience"],
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["token:key"])),
                    ClockSkew        = TimeSpan.Zero // remove delay of token when expire
                };
            });

            services.AddAuthorization();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Title       = "Smart App API V1",
                    Version     = "v1",
                    Description = "Smart App Web API written in ASP.NET Core Web API",
                    Contact     = new Contact {
                        Name = "Qinisela Molefe", Email = "*****@*****.**", Url = "https://www.codeassembly.co.za"
                    },
                });
            });

            services.AddCors(options =>
            {
                options.AddPolicy("all_origins", policy => policy.WithOrigins("*")
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials()
                                  );
            });
            services.AddMemoryCache();

            services.AddHttpClient <UCloudLinkClient>();

            services.AddDbContext <SmartAppContext>(options => options.UseNpgsql(Configuration.GetConnectionString("SmartApp_DB_Local")), ServiceLifetime.Transient);
            services.AddTransient <IUnitOfWork, UnitOfWork>();
            services.Configure <PayFastSettings>(Configuration.GetSection("PayFastSettings"));

            DataMappers.Initialise(services);
            BusinessRules.Initialise(services);
            Services.Initialise(services);
            UCloudLinkClients.Initialise(services);
            UCloudLinkServices.Initialise(services);
            PayFast.Initialise(services);
            ReferenceApiContainer.Initialise(services);

            services.AddScoped <LoginProvider>();
        }