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 InitializeApplication()
        {

            ApplicationApiModel applicationWebApiModel = new ApplicationApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            ApplicationInitializationBusinessService initializationBusinessService;

            initializationBusinessService = new ApplicationInitializationBusinessService(applicationDataService);
            initializationBusinessService.InitializeApplication(out transaction);

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

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

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

            applicationWebApiModel.ReturnMessage.Add("Application has been initialized.");
            applicationWebApiModel.ReturnStatus = transaction.ReturnStatus;
            applicationWebApiModel.MenuItems = menuItems;
            applicationWebApiModel.IsAuthenicated = User.Identity.IsAuthenticated;

            var response = Request.CreateResponse<ApplicationApiModel>(HttpStatusCode.OK, applicationWebApiModel);
            return response;
            
                
        }