コード例 #1
0
        public async Task CreateAsync(DataPoint dataPoint)
        {
            if (dataPoint == null)
            {
                throw new ArgumentNullException(nameof(dataPoint));
            }

            Context.DataPoints.Add(dataPoint);
            await Context.SaveChangesAsync();
        }
コード例 #2
0
        public async Task<IHttpActionResult> CreateDataPoint(int unitId, decimal value)
        {
            Unit unit = await DeviceRepository.GetUnitAsync(unitId);

            if (unit == null)
            {
                return BadRequest("Unit not found.");
            }

            DataPoint dataPoint = new DataPoint
            {
                Value = value,
                UnitId = unitId
            };
            await DataPointRepository.CreateAsync(dataPoint);

            return Ok();
        }
コード例 #3
0
 public DataPointRepositoryTests()
 {
     Repository = new DataPointRepository(new RepositoryContext());
     DataPoint = new DataPoint { Value = 15, UnitId = 1 };
 }