public async Task<DeviceResponseModel> Post([FromBody]DeviceRequestModel model) { var device = model.ToDevice(_userManager.GetUserId(User)); await _deviceService.SaveAsync(device); var response = new DeviceResponseModel(device); return response; }
public async Task<DeviceResponseModel> GetByIdentifier(string identifier) { var device = await _deviceRepository.GetByIdentifierAsync(identifier, new Guid(_userManager.GetUserId(User))); if(device == null) { throw new NotFoundException(); } var response = new DeviceResponseModel(device); return response; }
public async Task<DeviceResponseModel> Put(string id, [FromBody]DeviceRequestModel model) { var device = await _deviceRepository.GetByIdAsync(new Guid(id), new Guid(_userManager.GetUserId(User))); if(device == null) { throw new NotFoundException(); } await _deviceService.SaveAsync(model.ToDevice(device)); var response = new DeviceResponseModel(device); return response; }