public void InsertWarehouseSync(ShopifyLocation location, AcumaticaWarehouse warehouse) { var sync = new ShopAcuWarehouseSync(); sync.ShopifyLocation = location; sync.AcumaticaWarehouse = warehouse; sync.DateCreated = DateTime.UtcNow; sync.LastUpdated = DateTime.UtcNow; Entities.ShopAcuWarehouseSyncs.Add(sync); Entities.SaveChanges(); }
public static AcumaticaWarehouseModel Make(AcumaticaWarehouse warehouse) { var output = new AcumaticaWarehouseModel(); output.AcumaticaWarehouseId = warehouse.AcumaticaWarehouseId; if (warehouse.HasMatch()) { output.ShopifyLocationId = warehouse.MatchedLocation().ShopifyLocationId; } return(output); }
public void Run() { var warehouses = _acumaticaInventoryApi.RetrieveWarehouses().DeserializeFromJson <List <Warehouse> >(); var warehouseRecords = _dataRepository.RetrieveWarehouses(); foreach (var warehouse in warehouses) { using (var transaction = _dataRepository.BeginTransaction()) { var warehouseRecord = warehouseRecords.FindByAcumaticaId(warehouse); if (warehouseRecord == null) { var newDataWarehouse = new AcumaticaWarehouse { AcumaticaWarehouseId = warehouse.WarehouseID.value, DateCreated = DateTime.UtcNow, LastUpdated = DateTime.UtcNow, }; _dataRepository.InsertWarehouse(newDataWarehouse); } else { warehouseRecord.LastUpdated = DateTime.UtcNow; _dataRepository.SaveChanges(); } _acumaticaJsonService.Upsert( AcumaticaJsonType.SalesOrderShipments, warehouse.WarehouseID.value, warehouse.SerializeToJson()); transaction.Commit(); } } }
public void InsertWarehouse(AcumaticaWarehouse warehouse) { Entities.AcumaticaWarehouses.Add(warehouse); Entities.SaveChanges(); }
MatchedLocation(this AcumaticaWarehouse input) { return(input .ShopAcuWarehouseSyncs .FirstOrDefault()?.ShopifyLocation); }
public static bool HasMatch(this AcumaticaWarehouse warehouse) { return(warehouse.ShopAcuWarehouseSyncs.Any()); }
public static bool MatchesIdWithName( this ShopifyLocation location, AcumaticaWarehouse warehouse) { return(warehouse.AcumaticaWarehouseId == location.StandardizedName()); }
public static bool AutoMatches( this AcumaticaWarehouse warehouse, ShopifyLocation location) { return(warehouse.AcumaticaWarehouseId == location.StandardizedName()); }