TopShelfCustomer/TopShelfCustomer.Api/Controllers/UserController.cs
/// <summary>
/// GetUserByEmail:
///
/// Fetches a User from the UserData database wrapper class
/// by their email address.
/// </summary>
/// <param name="emailAddress"> The email address </param>
/// <returns> A User with that email address </returns>
/// <remarks>
/// Endpoints cannot handle the '.' operator. The caller must replace '.' with '-' before fetching
/// User.
/// </remarks>


Fetches a User from the UserData database wrapper class
by their email address.
Fetches a User from the UserData database wrapper class by their email address .
[Route( "api/User/GetUserByEmail/{emailAddress}" )]
        [HttpGet]
        public User GetUserByEmail ( string emailAddress ) {
            UserData data = new UserData();
            string sanitizedEmail = emailAddress.Replace( "-", "." );
            var user = data.GetUserByEmail( sanitizedEmail );
            try {               
                if ( user[0] == null ) { return new User(); }
            } catch ( ArgumentOutOfRangeException e ) {
                Debug.WriteLine( e.Message );
                return new User();
            } catch ( Exception e ) {
                Debug.WriteLine( e.Message );
                return new User();
            }
            return user[0];
        }
[ Route ( " " ) ] [ HttpGet ] public User GetUserByEmail ( string emailAddress ) { UserData data = new UserData ( ) ; string sanitizedEmail = emailAddress . Replace ( " " , " " ) ; var user = data . GetUserByEmail ( sanitizedEmail ) ; try { if ( user [ 0 ] == null ) { return new User ( ) ; } } catch ( ArgumentOutOfRangeException e ) { Debug . WriteLine ( e . Message ) ; return new User ( ) ; } catch ( Exception e ) { Debug . WriteLine ( e . Message ) ; return new User ( ) ; } return user [ 0 ] ; }
GetUserByEmail:
GetUserByEmail :
//Catch exceptions thrown by null User
A User with that email address
A User with that email address
emailAddress
string
The email address
The email address
remarks
Endpoints cannot handle the '.' operator. The caller must replace '.' with '-' before fetching
User.
Endpoints cannot handle the ' . ' operator . The caller must replace ' . ' with ' - ' before fetching User .