예제 #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();
        }
 public DataPointRepositoryTests()
 {
     Repository = new DataPointRepository(new RepositoryContext());
     DataPoint = new DataPoint { Value = 15, UnitId = 1 };
 }