示例#1
0
        public async Task <IActionResult> PutVegaTempDeviceData(long id, VegaMoveDeviceData tempDeviceData)
        {
            if (tempDeviceData is null)
            {
                return(BadRequest());
            }

            if (id != tempDeviceData.Id || !_repository.DeviceExists(tempDeviceData.DeviceId))
            {
                return(BadRequest());
            }

            try
            {
                await _repository.EditVegaDeviceDataAsync(tempDeviceData).ConfigureAwait(false);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_repository.MoveDeviceDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <VegaMoveDeviceData> AddVegaMovingDeviceDataAsync(VegaMoveDeviceData moveDeviceData, CancellationToken cancellationToken = default)
        {
            _context.MoveDeviceDatas.Add(moveDeviceData);
            await _context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);

            return(moveDeviceData);
        }
 public async Task EditVegaDeviceDataAsync(VegaMoveDeviceData vegaMoveDeviceData, CancellationToken cancellationToken = default)
 {
     _context.Entry(vegaMoveDeviceData).State = EntityState.Modified;
     await _context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
 }
示例#4
0
        public async Task <ActionResult <VegaMoveDeviceData> > PostVegaTempDeviceData(VegaMoveDeviceData tempDeviceData)
        {
            if (tempDeviceData is null)
            {
                throw new ArgumentNullException(nameof(tempDeviceData));
            }

            if (!_repository.DeviceExists(tempDeviceData.DeviceId))
            {
                return(BadRequest());
            }

            await _repository
            .AddVegaMovingDeviceDataAsync(tempDeviceData)
            .ConfigureAwait(false);

            return(CreatedAtAction("GetTempDeviceData", new { id = tempDeviceData.Id }, tempDeviceData));
        }