From 50279d34ac019cf3e18a6d4caf6af8a95ac030d5 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 18 Feb 2021 13:58:36 -0800 Subject: [PATCH] Disable shop change from partner. --- BodyshopUploader/ViewModels/MainViewModel.cs | 74 +++++++++----------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs index 06068b3..bcd6371 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.cs @@ -222,51 +222,45 @@ namespace BodyshopPartner.ViewModels { ShopData = Data.bodyshops.ToObject>(); } - string SettingsSelectedShopUuid = Properties.Settings.Default.LastSelectedShop; - if (string.IsNullOrEmpty(SettingsSelectedShopUuid)) - { - ActiveShop = ShopData[0] ?? null; - Properties.Settings.Default.LastSelectedShop = ShopData[0]?.Id ?? null; + + ActiveShop = ShopData.Where(_ => _.AssociationActive == true).FirstOrDefault(); + Properties.Settings.Default.LastSelectedShop = ActiveShop.Id ?? null; Properties.Settings.Default.Save(); - } - else - { - ActiveShop = ShopData.Where(_ => _.Id == SettingsSelectedShopUuid).FirstOrDefault(); - } + } public async Task SetActiveBodyshop() { - IndeterminateLoading = true; - foreach (var s in ShopData) - { - if (s.Id == ActiveShop?.Id) s.AssociationActive = true; - else s.AssociationActive = false; - var r = new GraphQLRequest - { - Query = @" - mutation UPDATE_ASSOCIATION($assocId: uuid, $assocActive: Boolean) { - update_associations(where: {id: {_eq: $assocId}}, _set: {active: $assocActive}) { - returning { - id - active - } - } - } - ", - Variables = new - { - assocId = s.AssociationId, - assocActive = s.AssociationActive - } - }; - await Utils.GraphQL.ExecuteQuery(r); - } - Properties.Settings.Default.LastSelectedShop = ActiveShop?.Id; - Properties.Settings.Default.Save(); - Utils.AppMetaData.ActiveShopId = ActiveShop?.Id; - Utils.AppMetaData.ShopRegion = ActiveShop?.RegionConfig; - IndeterminateLoading = false; + //IndeterminateLoading = true; + //foreach (var s in ShopData) + //{ + // if (s.Id == ActiveShop?.Id) s.AssociationActive = true; + // else s.AssociationActive = false; + // var r = new GraphQLRequest + // { + // Query = @" + // mutation UPDATE_ASSOCIATION($assocId: uuid, $assocActive: Boolean) { + // update_associations(where: {id: {_eq: $assocId}}, _set: {active: $assocActive}) { + // returning { + // id + // active + // } + // } + // } + //", + // Variables = new + // { + // assocId = s.AssociationId, + // assocActive = s.AssociationActive + // } + // }; + // await Utils.GraphQL.ExecuteQuery(r); + //} + //Properties.Settings.Default.LastSelectedShop = ActiveShop?.Id; + //Properties.Settings.Default.Save(); + //Utils.AppMetaData.ActiveShopId = ActiveShop?.Id; + //Utils.AppMetaData.ShopRegion = ActiveShop?.RegionConfig; + //IndeterminateLoading = false; } public void AddHttpStatus(string s)