public async Task <IActionResult> StoreEnergy([FromBody] LegacyModel legacyModel)
        {
            var raspberryPi = await dbDeviceRepository.GetDevice(legacyModel.RpiKey);

            if (raspberryPi == null)
            {
                return(Unauthorized());
            }

            var tenSecondMetrics = legacyModel.Data
                                   .Select(metric => new TenSecondMetric
            {
                UsageNow            = (int)double.Parse(metric.UsageNow),
                RedeliveryNow       = (int)double.Parse(metric.RedeliveryNow),
                SolarNow            = metric.SolarNow,
                UsageGasNow         = (int)double.Parse(metric.UsageGasNow),
                UsageTotalHigh      = (long)double.Parse(metric.UsageTotalHigh),
                RedeliveryTotalHigh = (long)double.Parse(metric.RedeliveryTotalHigh),
                UsageTotalLow       = (long)double.Parse(metric.UsageTotalLow),
                RedeliveryTotalLow  = (long)double.Parse(metric.RedeliveryTotalLow),
                UsageGasTotal       = (long)double.Parse(metric.UsageGasTotal),
                SolarTotal          = metric.SolarTotal,
                Mode        = int.Parse(metric.Mode),
                Created     = GetDateTimeFromUnixTimeStamp(metric.UnixTimeStamp),
                RaspberryPi = raspberryPi
            })
                                   .ToList();

            await dbTenSecondMetricRepository.StoreMetrics(tenSecondMetrics);

            return(Created("", ""));
        }
Exemple #2
0
        public IViewComponentResult Invoke(int id)
        {
            var model = new LegacyModel();

            var peoduct = _ps.GetProductById(id);

            if (peoduct != null)
            {
                model.PartNumber = peoduct.Sku;
                if (peoduct.ProductManufacturers.Count > 0)
                {
                    model.ManufacturerName = peoduct.ProductManufacturers.FirstOrDefault().Manufacturer.Name;
                }
            }

            return(View("~/Plugins/Misc.ProductWizard/Views/ExtraInfo.cshtml", model));
        }