Exemplo n.º 1
0
        public void SetAvailable(bool available)
        {
            if (IsOn)
            {
                TurnOff();
            }

            if (!available)
            {
                TemperatureReadings.Clear();
                PowerReadings.Clear();
                ReadingsUpdated?.Invoke(this, EventArgs.Empty);
            }

            IsAvailable = available;

            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsAvailable)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsOn)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(TurnOnEnabled)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(TurnOffEnabled)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Status)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(CoolerTabInfoVisibility)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(CoolerTabNotOnVisibility)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsOffVisibility)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsOnVisibility)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutPowerReadings(string id, PowerReadings loadDataTemplate)
        {
            if (id != loadDataTemplate.PowerReadingId)
            {
                return(BadRequest());
            }

            _context.Entry(loadDataTemplate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PowerReadingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        public void AddReading(DateTime readingTime, double?temperature, double?power)
        {
            LastReadingTime = readingTime;

            TemperatureReadings.Add(new DataPoint(DateTimeAxis.ToDouble(readingTime), temperature ?? double.NaN));
            PowerReadings.Add(new DataPoint(DateTimeAxis.ToDouble(readingTime), power ?? double.NaN));

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LastPowerReading)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LastTemperatureReading)));
            ReadingsUpdated?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 4
0
        public async Task <ActionResult <PowerReadings> > PostPowerReadings(IList <PowerReadings> loadData)
        {
            PowerReadings pr = new PowerReadings();

            foreach (PowerReadings loadDataTemplate in loadData)
            {
                loadDataTemplate.PowerReadingId = Guid.NewGuid().ToString();
                _context.PowerReadings.Add(loadDataTemplate);
                pr = loadDataTemplate;
            }
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPowerReadings", new { id = pr.PowerReadingId }, pr));
        }