Disable shop change from partner.

This commit is contained in:
Patrick Fic
2021-02-18 13:58:36 -08:00
parent 9694151246
commit 50279d34ac

View File

@@ -222,51 +222,45 @@ namespace BodyshopPartner.ViewModels
{
ShopData = Data.bodyshops.ToObject<ObservableCollection<Bodyshop>>();
}
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)