Example #1
0
        public async Task <IActionResult> DeleteApplication(Guid id)
        {
            var application = await _applicationService.GetAsync(id);

            if (application == null)
            {
                throw new Exception(ErrorMessages.NotFoundApplication);
            }

            var deviceConfigs = await _deviceConfigService.FindAllAsync(x => x.ApplicationId == application.Id);

            if (deviceConfigs.Count > 0)
            {
                throw new Exception(ErrorMessages.CanNotDeleteApplication);
            }

            var response = await _applicationService.DeleteAsync(application) == 1;

            return(Ok(new ApiOkResponse(response)));
        }
Example #2
0
        public async Task <IActionResult> Delete(Guid id)
        {
            var device = await _deviceService.GetAsync(id);

            if (device == null)
            {
                throw new Exception(ErrorMessages.NotFoundDevice);
            }

            var deviceConfigs = await _deviceConfigService.FindAllAsync(x => x.DeviceId == device.Id);

            if (deviceConfigs.Count > 0)
            {
                throw new Exception(ErrorMessages.CanNotDeleteDevice);
            }

            await _deviceService.DeleteAsync(id);

            return(Ok(new ApiOkResponse(true)));
        }