public bool RegisterCamera(CameraDetails cameraDetails) { try { if (cameraDetails.ImageDeleted) { DeleteCameraImage(cameraDetails); } if (cameraDetails.UploadedImage == null || PerformCameraImageUpload(cameraDetails)) { if (cameraDetails.ExistingRoomId <= 0) { DatabaseRoom dbRoom = new DatabaseRoom(cameraDetails); dbRoom.EscapeStringFields(); if (!_dbQueryService.PersistNewRoom(dbRoom)) { return(false); } cameraDetails.ExistingRoomId = _dbQueryService.GetRoomIdByLocationIdAndRoomName(dbRoom.LocationId, dbRoom.RoomName); } DatabaseCamera dbCamera = new DatabaseCamera(cameraDetails); dbCamera.EscapeStringFields(); return(_dbQueryService.PersistExistingCameraByCameraKey(dbCamera, cameraDetails.ImageDeleted)); } } catch (Exception e) { logger.Error(e); } return(false); }