/// <summary>
 /// Sets the Name of a Meter or a Folder
 /// </summary>
 /// <param name="accessToken">The OAuth2 access token</param>
 /// <param name="meterFolderInformation">The Id of the meter or folder and the Name to be set</param>
 /// <param name="resultHandler">The result handler</param>
 /// <returns></returns>
 public static async Task <IActionResult> SetMeterFolderInformationAsync(
     string accessToken,
     MeterFolderInformationToSet meterFolderInformation,
     ResultHandler <MeterFolderInformationToSet> resultHandler)
 {
     using (var restApi = new SmartMeApiClient(accessToken))
     {
         return(await restApi.PostAsync <MeterFolderInformationToSet>("MeterFolderInformation", meterFolderInformation, resultHandler));
     }
 }
Exemple #2
0
        public async Task <IActionResult> OnPostAsync(MeterFolderInformationToSet infoToSet)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("/"));
            }

            var tokenData = await SmartMeOAuthConfiguration.GetAccessToken(HttpContext);

            return(await FolderApi.SetMeterFolderInformationAsync(
                       tokenData.AccessToken,
                       infoToSet,
                       new ResultHandler <MeterFolderInformationToSet>
            {
                OnSuccess = (empty) =>
                {
                    // Trigger another GET to show the updated MeterFolderInformation
                    return Redirect("/Folder/GetMeterFolderInformation");
                },

                OnError = DefaultErrorHandler.Handle
            }
                       ));
        }
Exemple #3
0
        public async Task <IActionResult> OnGetAsync()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("/"));
            }

            var tokenData = await SmartMeOAuthConfiguration.GetAccessToken(HttpContext);

            return(await FolderApi.GetMeterFolderInformationAsync(tokenData.AccessToken, Id, new ResultHandler <MeterFolderInformation>
            {
                OnSuccess = (info) =>
                {
                    InfoToSet = new MeterFolderInformationToSet
                    {
                        Id = Id,
                        Name = info.Name
                    };
                    return Page();
                },

                OnError = DefaultErrorHandler.Handle
            }));
        }
 /// <summary>
 /// Sets the Name of a Meter or a Folder
 /// </summary>
 /// <param name="accessToken">The OAuth2 access token</param>
 /// <param name="meterFolderInformation">The Id of the meter or folder and the Name to be set</param>
 /// <returns></returns>
 public static async Task <bool> SetMeterFolderInformationAsync(string accessToken, MeterFolderInformationToSet meterFolderInformation)
 {
     using (var restApi = new SmartMeApiClient(accessToken))
     {
         return(await restApi.PostAsync <MeterFolderInformationToSet>("MeterFolderInformation", meterFolderInformation));
     }
 }
 /// <summary>
 /// Sets the Name of a Meter or a Folder
 /// </summary>
 /// <param name="usernamePassword">The Username and Password for Basic Authentication</param>
 /// <param name="meterFolderInformation">The Id of the meter or folder and the Name to be set</param>
 /// <returns></returns>
 public static async Task <bool> SetMeterFolderInformationAsync(UserPassword usernamePassword, MeterFolderInformationToSet meterFolderInformation)
 {
     using (var restApi = new SmartMeApiClient(usernamePassword))
     {
         return(await restApi.PostAsync <MeterFolderInformationToSet>("MeterFolderInformation", meterFolderInformation));
     }
 }