Example #1
0
    public async void SaveParameters()
    {
        if (Base.Parameter.CheckIfAllValuesValid(objectParameters))
        {
            List <IO.Swagger.Model.Parameter> parameters = new List <IO.Swagger.Model.Parameter>();
            foreach (IParameter p in objectParameters)
            {
                if (CurrentObject.TryGetParameterMetadata(p.GetName(), out IO.Swagger.Model.ParameterMeta parameterMeta))
                {
                    IO.Swagger.Model.ParameterMeta metadata = parameterMeta;
                    IO.Swagger.Model.Parameter     ap       = new IO.Swagger.Model.Parameter(name: p.GetName(), value: JsonConvert.SerializeObject(p.GetValue()), type: metadata.Type);
                    parameters.Add(ap);
                }
                else
                {
                    Notifications.Instance.ShowNotification("Failed to save parameters!", "");
                }
            }

            try {
                await WebsocketManager.Instance.UpdateObjectParameters(CurrentObject.Data.Id, parameters, false);

                Base.Notifications.Instance.ShowToastMessage("Parameters saved");
                parametersChanged = false;
                UpdateSaveBtn();
            } catch (RequestFailedException e) {
                Notifications.Instance.ShowNotification("Failed to update object parameters ", e.Message);
            }
        }
    }