//returns "MODEL.User" object if successful/found //returns "null" if not internal User findUserByUserName(string userName) { int result = (int)CODE.MINUS_ONE; User user = null; //validate userName if ( result == (int)CODE.ZERO || string.IsNullOrWhiteSpace(userName) || !Validate.isAlphaNumericWithUnderscore(userName) || !Validate.hasMinLength(userName, 5) || !Validate.hasMaxLength(userName, 15) ) { result = (int)CODE.ZERO; } if (result != (int)CODE.ZERO)//safe to proceed { IUsers _DbUsers = new DbUsers(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { user = _DbUsers.findUserByUserName(userName); 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); } }