public async Task <bool> Verify_SupplierTags(string tags) { CreateAPI(); InventoryLevels iLevels = await _api.GetInventoryLevels(this.InventoryItemId.ToString()); if (iLevels.Levels == null) { return(false); } if (iLevels.Levels.Count > 1) { return(false); } if (!common.DoesSupplierTagMatchesLocationID(iLevels.Levels[0].LocationId, tags)) { return(false); } return(true); }
public async Task <bool> FixSupplierLocation(string sup_tag, bool whatif = false) { // Get inventorylevels. There should only be one // if there are multiple, find the shipping tag and match to that // remove the non matching ones // if there's one make sure shipping tag matches invlocationid. // if there are none then add one matched to shipping tag CreateAPI(); bool retval = false; InventoryLevels iLevels = await _api.GetInventoryLevels(this.InventoryItemId.ToString()); Dictionary <string, long> locationList = SupplierProducer.GetSupplierLocationIDs(); if ((iLevels.Levels == null) | (iLevels.Levels.Count == 0)) { if (locationList.ContainsKey(sup_tag)) { if (!whatif) { await _api.ConnectInventoryItemLocation(this.InventoryItemId, locationList[sup_tag]); } retval = true; } else { retval = false; } } if (iLevels.Levels.Count == 1) { if (locationList[sup_tag] != iLevels.Levels[0].LocationId) { await _api.ConnectInventoryItemLocation(this.InventoryItemId, locationList[sup_tag]); await _api.Remove_InventoryItemLocation(this.InventoryItemId, iLevels.Levels[0].LocationId); } } if (iLevels.Levels.Count > 1) { foreach (InventoryLevel level in iLevels.Levels) { if (level.LocationId != locationList[sup_tag]) { if (!whatif) { await _api.Remove_InventoryItemLocation(this.InventoryItemId, level.LocationId); } retval = true; } } } return(retval); }