Beispiel #1
0
        public async Task <PeripheralResponse> SaveAsync(PeripheralDevice peripheral)
        {
            var gateway = await _gatewayService.FindByIDAsync(peripheral.GatewayID);

            if (gateway == null)
            {
                return(new PeripheralResponse($"An error ocurred triying to save the Peripheral Device : The specified gateway does not exist."));
            }

            try
            {
                await _repo.SaveAsync(peripheral);

                await _unitOfWork.CompleteTask();

                return(new PeripheralResponse(peripheral));
            }
            catch (Exception ex)
            {
                return(new PeripheralResponse($"An error ocurred triying to save the Peripheral Device : {ex.Message}"));
            }
        }