//returns "MODEL.User" object if successful/found //returns "null" if not internal User findUserByUserId(int userId) { int result = (int)CODE.MINUS_ONE; User user = null; //validate userId if ( result == (int)CODE.ZERO || string.IsNullOrWhiteSpace(userId.ToString()) || !Validate.isAllNumbers(userId.ToString()) || !Validate.integerIsBiggerThan(userId, (int)CODE.TRANSLATO_DATABASE_SEED - 1) ) { result = (int)CODE.ZERO; } if (result != (int)CODE.ZERO)//safe to proceed { IUsers _DbUsers = new DbUsers(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { user = _DbUsers.findUserByUserId(userId); trScope.Complete(); } } catch (TransactionAbortedException taEx) { result = (int)CODE.ZERO; Log.Add(taEx.ToString()); } catch (ApplicationException aEx) { result = (int)CODE.ZERO; Log.Add(aEx.ToString()); } catch (Exception ex) { result = (int)CODE.ZERO; Log.Add(ex.ToString()); } } else { result = (int)CODE.ZERO; } if (result == (int)CODE.ZERO || user == null) { return(null); } else { return(user); } }