public HttpResponseMessage RegisterUser(HttpRequestMessage request, [FromBody] UserDTO registerUserDTO)
        {

            AccountsApiModel accountsWebApiModel = new AccountsApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            AccountsBusinessService accountsBusinessService;
          
            if (registerUserDTO.FirstName == null) registerUserDTO.FirstName = "";
            if (registerUserDTO.LastName == null) registerUserDTO.LastName = "";
            if (registerUserDTO.EmailAddress == null) registerUserDTO.EmailAddress = "";
            if (registerUserDTO.UserName == null) registerUserDTO.UserName = "";
            if (registerUserDTO.Password == null) registerUserDTO.Password = "";
            if (registerUserDTO.PasswordConfirmation == null) registerUserDTO.PasswordConfirmation = "";
      
            accountsBusinessService = new AccountsBusinessService(accountsDataService);
            User user = accountsBusinessService.RegisterUser(
                registerUserDTO.FirstName, 
                registerUserDTO.LastName,
                registerUserDTO.UserName,
                registerUserDTO.EmailAddress,                
                registerUserDTO.Password, 
                registerUserDTO.PasswordConfirmation, 
                out transaction);

            if (transaction.ReturnStatus == false)
            {
                accountsWebApiModel.ReturnMessage = transaction.ReturnMessage;
                accountsWebApiModel.ReturnStatus = transaction.ReturnStatus;
                accountsWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse<AccountsApiModel>(HttpStatusCode.BadRequest, accountsWebApiModel);
                return badResponse;
            }

            ApplicationInitializationBusinessService initializationBusinessService;
            initializationBusinessService = new ApplicationInitializationBusinessService(applicationDataService);
            List<ApplicationMenu> menuItems = initializationBusinessService.GetMenuItems(true, out transaction);

            if (transaction.ReturnStatus == false)
            {
                accountsWebApiModel.ReturnMessage = transaction.ReturnMessage;
                accountsWebApiModel.ReturnStatus = transaction.ReturnStatus;
                var badResponse = Request.CreateResponse<AccountsApiModel>(HttpStatusCode.BadRequest, accountsWebApiModel);
                return badResponse;
            }

            accountsWebApiModel.IsAuthenicated = true;
            accountsWebApiModel.ReturnStatus = transaction.ReturnStatus;         
            accountsWebApiModel.ReturnMessage.Add("Register User successful.");
            accountsWebApiModel.MenuItems = menuItems;
            accountsWebApiModel.User = user;

            FormsAuthentication.SetAuthCookie(user.UserId.ToString(), createPersistentCookie: false);

            var response = Request.CreateResponse<AccountsApiModel>(HttpStatusCode.OK, accountsWebApiModel);
            return response;


        }
        public HttpResponseMessage GetUser()   
        {

            Guid userID = new Guid(User.Identity.Name);

            AccountsApiModel accountsWebApiModel = new AccountsApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            AccountsBusinessService accountsBusinessService;
            accountsWebApiModel.IsAuthenicated = true;

            accountsBusinessService = new AccountsBusinessService(accountsDataService);
            User user = accountsBusinessService.GetUser(userID, out transaction);
           
            transaction.ReturnStatus = true;

            if (transaction.ReturnStatus == false)
            {
                accountsWebApiModel.ReturnMessage = transaction.ReturnMessage;
                accountsWebApiModel.ReturnStatus = transaction.ReturnStatus;
                accountsWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse<AccountsApiModel>(HttpStatusCode.BadRequest, accountsWebApiModel);
                return badResponse;
            }

            accountsWebApiModel.ReturnStatus = transaction.ReturnStatus;               
            accountsWebApiModel.User = user;

            var response = Request.CreateResponse<AccountsApiModel>(HttpStatusCode.OK, accountsWebApiModel);
            return response;


        }
        public HttpResponseMessage UpdateUser(HttpRequestMessage request, [FromBody] UserDTO updateUserDTO)
        {

            Guid userID = new Guid(User.Identity.Name);

            AccountsApiModel accountsWebApiModel = new AccountsApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            AccountsBusinessService accountsBusinessService;
            accountsWebApiModel.IsAuthenicated = true;

            if (updateUserDTO.FirstName == null) updateUserDTO.FirstName = "";
            if (updateUserDTO.LastName == null) updateUserDTO.LastName = "";
            if (updateUserDTO.EmailAddress == null) updateUserDTO.EmailAddress = "";
            if (updateUserDTO.UserName == null) updateUserDTO.UserName = "";
            if (updateUserDTO.Password == null) updateUserDTO.Password = "";
            if (updateUserDTO.PasswordConfirmation == null) updateUserDTO.PasswordConfirmation = "";

            accountsBusinessService = new AccountsBusinessService(accountsDataService);
            User user = accountsBusinessService.UpdateUser(
                userID,
                updateUserDTO.FirstName,
                updateUserDTO.LastName,
                updateUserDTO.UserName,
                updateUserDTO.EmailAddress,
                updateUserDTO.Password,
                updateUserDTO.PasswordConfirmation,
                out transaction);

            if (transaction.ReturnStatus == false)
            {
                accountsWebApiModel.ReturnMessage = transaction.ReturnMessage;
                accountsWebApiModel.ReturnStatus = transaction.ReturnStatus;
                accountsWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse<AccountsApiModel>(HttpStatusCode.BadRequest, accountsWebApiModel);
                return badResponse;
            }
          
            accountsWebApiModel.ReturnStatus = transaction.ReturnStatus;
            accountsWebApiModel.ReturnMessage.Add("User successful updated.");
                      
            var response = Request.CreateResponse<AccountsApiModel>(HttpStatusCode.OK, accountsWebApiModel);
            return response;

        }