public async Task <IActionResult> OnGetAsync() { if (!User.Identity.IsAuthenticated) { return(Redirect("/")); } var accessToken = await HttpContext.GetTokenAsync("access_token"); return(await ValuesApi.GetDeviceValuesInPastMultipleAsync( accessToken, Id, DateFrom, DateTo, 60, new ResultHandler <List <DeviceValues> > { OnSuccess = (valuesList) => { ValuesList = valuesList; return Page(); }, OnError = DefaultErrorHandler.Handle })); }
public async Task <IActionResult> OnGetAsync() { if (!User.Identity.IsAuthenticated) { return(Redirect("/")); } var tokenData = await SmartMeOAuthConfiguration.GetAccessToken(HttpContext); return(await ValuesApi.GetDeviceValuesInPastMultipleAsync( tokenData.AccessToken, Id, DateFrom, DateTo, 60, new ResultHandler <List <DeviceValues> > { OnSuccess = (valuesList) => { ValuesList = valuesList; return Page(); }, OnError = DefaultErrorHandler.Handle })); }
public IActionResult AddPizza(PIZZAS pizza, SIZES size, CRUSTS crust, List <TOPPINGS> topping) { var API = new ValuesApi(new Configuration { BasePath = "https://localhost:44368/" }); var fleshedOutPizza = API.ApiValuesPIZZASIZECRUSTGet(pizza, size, crust, topping); return(PizzaMenu(new List <APizza> { fleshedOutPizza })); }
public IActionResult AddHawaiianFeast() { var sessionOrder = Utils.GetCurrentOrder(HttpContext.Session); var API = new ValuesApi(new Configuration { BasePath = "https://localhost:44368/" }); List <APizza> fleshedOutPizza = new List <APizza>(); for (int i = 0; i < 16; i++) { var pizza = PIZZAS.HAWAIIAN; var size = SIZES.LARGE; var apizza = API.ApiValuesPIZZASIZEGet(pizza, size); fleshedOutPizza.Add(apizza); } return(PizzaMenu(fleshedOutPizza)); }
public async Task <IActionResult> OnGetAsync() { if (!User.Identity.IsAuthenticated) { return(Redirect("/")); } var tokenData = await SmartMeOAuthConfiguration.GetAccessToken(HttpContext); return(await ValuesApi.GetMeterValuesAsync(tokenData.AccessToken, Id, Date, new ResultHandler <MeterValues> { OnSuccess = (values) => { Values = values; return Page(); }, OnError = DefaultErrorHandler.Handle })); }
public async Task <IActionResult> OnGetAsync() { if (!User.Identity.IsAuthenticated) { return(Redirect("/")); } var accessToken = await HttpContext.GetTokenAsync("access_token"); return(await ValuesApi.GetMeterValuesAsync(accessToken, Id, Date, new ResultHandler <MeterValues> { OnSuccess = (values) => { Values = values; return Page(); }, OnError = DefaultErrorHandler.Handle })); }
public ValuesController(ILogger <ValuesController> logger, ValuesApi api) { m_Logger = logger; m_Api = api; }
public void Init() { instance = new ValuesApi(); }
public static async Task ValuesAsync(UserPassword credentials) { // We will use this device to fetch its details later Device sampleDevice; // Get all devices { Helpers.WriteConsoleTitle("Get all devices"); List <Device> devices = await DevicesApi.GetDevicesAsync(credentials); foreach (var device in devices) { Console.WriteLine($"Id: {device.Id}, Name: {device.Name}"); } // Store the first device. Make sure you have at least one device in your smart-me account. sampleDevice = devices.First(); } // Get Values { Helpers.WriteConsoleTitle("Get Values"); var deviceValues = await ValuesApi.GetDeviceValuesAsync(credentials, sampleDevice.Id); foreach (var deviceValue in deviceValues.Values) { Console.WriteLine($"Obis: {deviceValue.Obis}, Value: {deviceValue.Value}"); } } // Get Values In Past { Helpers.WriteConsoleTitle("Get Values In Past"); var deviceValues = await ValuesApi.GetDeviceValuesInPastAsync(credentials, sampleDevice.Id, new DateTime(2019, 8, 16, 12, 0, 0, DateTimeKind.Utc)); foreach (var deviceValue in deviceValues.Values) { Console.WriteLine($"Obis: {deviceValue.Obis}, Value: {deviceValue.Value}"); } } // Get Values In Past Multiple { Helpers.WriteConsoleTitle("Get Values In Past Multiple"); var multipleDeviceValues = await ValuesApi.GetDeviceValuesInPastMultipleAsync( credentials, sampleDevice.Id, new DateTime(2019, 8, 5, 10, 0, 0, DateTimeKind.Utc), new DateTime(2019, 8, 5, 12, 0, 0, DateTimeKind.Utc), 5); foreach (var deviceValues in multipleDeviceValues) { Console.WriteLine(deviceValues.Date); foreach (var deviceValue in deviceValues.Values) { Console.WriteLine($"Obis: {deviceValue.Obis}, Value: {deviceValue.Value}"); } } } // Get Meter Values { Helpers.WriteConsoleTitle("Get Meter Values"); var meterValues = await ValuesApi.GetMeterValuesAsync(credentials, sampleDevice.Id, new DateTime(2019, 8, 5, 12, 0, 0, DateTimeKind.Utc)); Console.WriteLine($"CounterReading: {meterValues.CounterReading}, CounterReadingImport: {meterValues.CounterReadingImport}"); } }