public void RunItemClass()
        {
            var json      = _referenceApi.RetrieveItemClass();
            var reference = _dataRepository.RetrieveAcumaticaRefData();

            reference.AcumaticaItemClass = json;
            _dataRepository.SaveChanges();
        }
Example #2
0
        public CombinedReferenceData RetrieveRefData()
        {
            var reference = _referenceDataRepository.RetrieveAcumaticaRefData();
            var timeZones = _instanceTimeZoneService.RetrieveTimeZones();
            var gateways  = _paymentGatewayService.Retrieve();

            var itemClasses =
                reference.AcumaticaItemClass.IsNullOrEmptyAlt("[]")
                .DeserializeFromJson <List <ItemClass> >()
                //.Where(x => x.DefaultWarehouseID?.value != null)
                .Select(x => new ItemClassModel(x))
                .ToList();

            var paymentMethods =
                reference.AcumaticaPaymentMethod.IsNullOrEmptyAlt("[]")
                .DeserializeFromJson <List <AcumaticaPaymentMethod> >()
                .Select(x => new PaymentMethodModel(x))
                .Where(x => x.Validation.Success)
                .ToList();

            var taxIds =
                reference.AcumaticaTaxId.IsNullOrEmptyAlt("[]")
                .DeserializeFromJson <List <Tax> >()
                .Select(x => x.TaxID.value)
                .ToList();

            var taxCategories =
                reference.AcumaticaTaxCategory.IsNullOrEmptyAlt("[]")
                .DeserializeFromJson <List <TaxCategory> >()
                .Select(x => x.TaxCategoryID.value)
                .ToList();

            var taxZones =
                reference.AcumaticaTaxZone.IsNullOrEmptyAlt("[]")
                .DeserializeFromJson <List <TaxZone> >()
                .Select(x => x.TaxZoneID.value)
                .ToList();

            var customerClasses =
                reference.AcumaticaCustomerClass.IsNullOrEmptyAlt("[]")
                .DeserializeFromJson <List <CustomerClass> >()
                .Select(x => x.ClassID.value)
                .ToList();

            var shipVia =
                reference.AcumaticaShipVia.IsNullOrEmptyAlt("[]")
                .DeserializeFromJson <List <AcumaticaShipVia> >()
                .Select(x => x.CarrierID.value)
                .ToList();


            var output = new CombinedReferenceData()
            {
                TimeZones        = timeZones,
                ItemClasses      = itemClasses,
                PaymentGateways  = gateways,
                PaymentMethods   = paymentMethods,
                TaxIds           = taxIds,
                TaxCategories    = taxCategories,
                TaxZones         = taxZones,
                CustomerClasses  = customerClasses,
                AcumaticaShipVia = shipVia,
            };

            return(output);
        }