Ejemplo n.º 1
0
        public async Task <DeviceResponseModel> Post([FromBody] DeviceRequestModel model)
        {
            var device = model.ToDevice(_userService.GetProperUserId(User));
            await _deviceService.SaveAsync(device);

            var response = new DeviceResponseModel(device);

            return(response);
        }
Ejemplo n.º 2
0
        public async Task <DeviceResponseModel> Put(string id, [FromBody] DeviceRequestModel model)
        {
            var device = await _deviceRepository.GetByIdAsync(new Guid(id), _userService.GetProperUserId(User).Value);

            if (device == null)
            {
                throw new NotFoundException();
            }

            await _deviceService.SaveAsync(model.ToDevice(device));

            var response = new DeviceResponseModel(device);

            return(response);
        }