예제 #1
0
        /// <summary>
        /// Get User
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public taccount GetUser(int userID, out TransactionalInformation transaction)
        {
            transaction = new TransactionalInformation();

            AdminBusinessRules accountsBusinessRules = new AdminBusinessRules();

            taccount user = new taccount();

            try
            {
                accountsDataService.CreateSession();
                user = accountsDataService.GetUser(userID);

                if (user != null)
                {
                    transaction.ReturnStatus = true;
                }
                else
                {
                    transaction.ReturnStatus = false;
                    transaction.ReturnMessage.Add("user id not found.");
                }
            }
            catch (Exception ex)
            {
                transaction.ReturnMessage = new List <string>();
                string errorMessage = ex.Message;
                transaction.ReturnStatus = false;
                transaction.ReturnMessage.Add(errorMessage);
            }
            finally
            {
                accountsDataService.CloseSession();
            }

            return(user);
        }
        /// <summary>
        /// Initialize Application
        /// </summary>
        /// <param name="transaction"></param>
        public void InitializeApplication(out TransactionalInformation transaction)
        {
            transaction = new TransactionalInformation();

            try
            {
                applicationDataService.CreateSession();
                applicationDataService.InitializeApplication();
                applicationDataService.CommitTransaction(true);
                transaction.ReturnStatus = true;
                transaction.ReturnMessage.Add("Application has been initialized.");
            }
            catch (Exception ex)
            {
                transaction.ReturnMessage = new List <string>();
                string errorMessage = ex.Message;
                transaction.ReturnStatus = false;
                transaction.ReturnMessage.Add(errorMessage);
            }
            finally
            {
                applicationDataService.CloseSession();
            }
        }
예제 #3
0
        /// <summary>
        /// Register User
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="userName"></param>
        /// <param name="emailAddress"></param>
        /// <param name="password"></param>
        /// <param name="passwordConfirmation"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public taccount RegisterUser(string firstName, string lastName, string userName, string emailAddress, string password, string passwordConfirmation, out TransactionalInformation transaction)
        {
            transaction = new TransactionalInformation();

            AdminBusinessRules accountsBusinessRules = new AdminBusinessRules();

            taccount user = new taccount();

            try
            {
                //user.FirstName = Utilities.UppercaseFirstLetter(firstName.Trim());
                //user.LastName = Utilities.UppercaseFirstLetter(lastName.Trim());
                //user.EmailAddress = emailAddress.Trim();
                //user.Password = password.Trim();
                //user.UserName = userName.Trim();

                accountsDataService.CreateSession();

                accountsBusinessRules.ValidateUser(user, accountsDataService);
                accountsBusinessRules.ValidatePassword(password, passwordConfirmation);

                if (accountsBusinessRules.ValidationStatus == true)
                {
                    accountsDataService.BeginTransaction();
                    //accountsDataService.RegisterUser(user);
                    accountsDataService.CommitTransaction(true);
                    transaction.ReturnStatus = true;
                    transaction.ReturnMessage.Add("User registered successfully.");
                }
                else
                {
                    transaction.ReturnStatus     = accountsBusinessRules.ValidationStatus;
                    transaction.ReturnMessage    = accountsBusinessRules.ValidationMessage;
                    transaction.ValidationErrors = accountsBusinessRules.ValidationErrors;
                }
            }
            catch (Exception ex)
            {
                transaction.ReturnMessage = new List <string>();
                string errorMessage = ex.Message;
                transaction.ReturnStatus = false;
                transaction.ReturnMessage.Add(errorMessage);
            }
            finally
            {
                accountsDataService.CloseSession();
            }

            return(user);
        }