public LoginResponse Login(User userData)
        {
            try
            {
            #warning TODO:all responses should just use the generic ResponseDataStore<Type>
                RequestLogin rl = new RequestLogin
                {
                    username = userData.username,
                    password = userData.password
                };
                ResponseDatastore<User> response = base.GetResponse<User>(rl, null, DatastoreType.Login);

            #warning TODO:need to find out the response when login fails.
                LoginResponse lr = new LoginResponse
                {
                    User = response?.ResponseBody,
                    ResponseMessage = response?.ResponseBody == null ? "Login failed" : "",
                    ResponseValue = response?.ResponseBody != null
                };
                return lr;
            }//try
            catch (Exception ex)
            {
                ex.Data["User Login Data"] = userData.ToXml() + "";
                return new LoginResponse
                {
                    ResponseMessage = ex.GetBaseException().Message,
                    ResponseValue = false,
                    User = null,
                };
            }
        }
        public LoginResponse Logout(User userData)
        {
            ResponseDatastore<User> r = base.GetObject<User>(null, new Dictionary<string, string>(1) { { "username", userData.username } });
            if (r != null && r.HttpStatusCode == HttpStatusCode.OK && r.ResponseBody != null)
            {
                User u = r.ResponseBody;
                u.sessionToken = null;
            #warning TODO: can we make the expiration field nullable? or will parse not like a nullable date field?

            #warning will we be able to null out a token without a token?
                ResponseDatastore<ObjectUpdatedResponse> updateResponse = base.UpdateObject(u, null);

                LoginResponse lr = new LoginResponse
                {
                    ResponseValue = updateResponse?.ResponseBody != null,
                    ResponseMessage = updateResponse?.ResponseBody == null ? "Error logging out" : ""
                };
                return lr;
            }//if
            return new LoginResponse
            {
                ResponseMessage = "User does not exist",
                ResponseValue = false
            };
        }
        public RegistrationResponse Register(User user)
        {
            try
            {
                bool validUser = this.ValidateUserRegistration(user);

                if (validUser)
                {
                    ResponseDatastore<ObjectCreatedResponse> rp = base.PostResponse<ObjectCreatedResponse>(user,
                        user.sessionToken, DatastoreType.Users);

                    bool created = rp != null && rp.HttpStatusCode == HttpStatusCode.Created;

                    return new RegistrationResponse
                    {
                        ResponseValue = created,
                        ResponseMessage = created ? "" : "Error registering user."
                    };
                }//if

                return new RegistrationResponse
                {
                    ResponseValue = false,
                    ResponseMessage = "User already exists."
                };
            }
            catch (Exception ex)
            {
                ex.Data["User"] = user.ToXml() + "";
                throw;
            }
        }
        private bool ValidateUserRegistration(User user)
        {
            try
            {
                bool isNewUser = this.CheckDuplicateRegistration(user.email);

                return isNewUser;
            }//try
            catch (Exception ex)
            {
                ex.Data["User"] = user.ToXml() + "";
                return false;
            }
        }
        //[TestMethod]
        public void CheckOutTest()
        {
            User data = new User
            {
                sessionToken = "",
                garageID = "",
                username = "******"
            };

            LocationResponse lr = this.locationRepository.CheckOut(data);

            Assert.IsNotNull(lr);

            Assert.IsTrue(lr.ResponseValue);

            Assert.IsTrue(string.IsNullOrWhiteSpace(lr.ResponseMessage));
        }
        public LocationResponse CheckOut(User data)
        {
            try
            {
                ResponseDatastore<User> r = base.GetObject<User>(data.sessionToken, new Dictionary<string, string>(1) { { "userName", data.username } });

                if (r == null
                    || r.HttpStatusCode != HttpStatusCode.OK
                    || r.ResponseBody == null
                    || !string.IsNullOrWhiteSpace(r.ResponseBody.garageID))
                {
                    return new LocationResponse
                    {
                        ResponseValue = false,
                        ResponseMessage =
                            r == null
                            ? "User was not found! Unable to check out."
                            : "User is not checked in! Unable to check out!"
                    };
                }//if

                User u = r.ResponseBody;
                u.garageID = null;

                ResponseDatastore<ObjectUpdatedResponse> updateResponse = base.UpdateObject(u, data.sessionToken);

                LocationResponse lr = new LocationResponse
                {
                    ResponseValue = updateResponse?.ResponseBody != null,
                    ResponseMessage = "",
                };

                return lr;
            }//try
            catch (Exception ex)
            {
                ex.Data["Checkin Data"] = data.ToXml() + "";
                return new LocationResponse
                {
                    ResponseMessage = ex.GetBaseException().Message,
                    ResponseValue = false
                };
            }//catch
        }
 public LoginResponse Logout(User userData)
 {
     return this.loginRepository.Logout(userData);
 }
 public LocationResponse CheckOut(User data)
 {
     return this.locationRepository.CheckOut(data);
 }
 public RegistrationResponse Register(User userData)
 {
     return this.registrationRepository.Register(userData);
 }