currentUserUpdate method
RemoteDto
currentUserUpdate(
- RemoteDto pRemoteDto,
- UserDto pRemoteUserDto,
- UserStoreDto pUserStoreDto,
- int userId,
- DbTransaction transaction,
Implementation
RemoteDto currentUserUpdate(RemoteDto pRemoteDto, UserDto pRemoteUserDto,
UserStoreDto pUserStoreDto, int userId, DbTransaction transaction) {
if (remoteWardenType == WardenType.USER) {
UserStoreDto receivedUserStoreDto =
UserStoreDto.map(pRemoteDto.trDto.toMap());
if (receivedUserStoreDto.id! < UserStoreMixin.min_id_for_user) {
receivedUserStoreDto.id = userId;
} else {
throw RemoteStatusException(RemoteStatus.WRONG_USER_ID);
}
// Ensure user email address is not used by another user
remoteWardenType = WardenType.WRITE_SERVER;
pRemoteDto.waterLineDto!.water_state = WaterState.SERVER_APPROVED;
// Change ts to null so that server will use the latest ts
pRemoteDto.trDto.ts = null;
// Force records which user is not allowed to change
receivedUserStoreDto.email = pUserStoreDto.email;
receivedUserStoreDto.records_downloaded =
pUserStoreDto.records_downloaded;
receivedUserStoreDto.changes_approved_count =
pUserStoreDto.changes_approved_count;
receivedUserStoreDto.changes_denied_count =
pUserStoreDto.changes_denied_count;
pRemoteDto.trDto.append(receivedUserStoreDto,
field_table_id: receivedUserStoreDto.table_id);
}
return pRemoteDto;
}