コード例 #1
0
        internal IValidationResult Account(Account account)
        {
            IValidationResult validationResult = new ValidationResult();

            var subscriptionPlan = this.doctrineShipsRepository.GetSubscriptionPlan(account.SubscriptionPlanId);

            // Null checks.
            if (account.Description == string.Empty || account.Description == null)
            {
                validationResult.AddError("Description.Null", "Description can not be empty or null.");
            }
            else
            {
                // Range checks.
                if (account.Description.Length > 30)
                {
                    validationResult.AddError("Description.Length", "Description should be less than 30 characters in length.");
                }
            }

            // Does the subscription plan exist in the database?
            if (subscriptionPlan == null)
            {
                validationResult.AddError("SubscriptionPlan.Null", "The subscription plan does not exist in the database.");
            }

            return validationResult;
        }
コード例 #2
0
 public void UpdateAccount(Account account)
 {
     AccountOperations.UpdateAccount(account);
 }
コード例 #3
0
 public Account CreateAccount(Account account)
 {
     return AccountOperations.CreateAccount(account);
 }
コード例 #4
0
 public Account AddAccount(Account account)
 {
     return AccountOperations.AddAccount(account);
 }
コード例 #5
0
 internal Account CreateAccount(Account account)
 {
     account.ObjectState = ObjectState.Added;
     this.unitOfWork.Repository<Account>().Insert(account);
     return account;
 }
コード例 #6
0
 internal Account AddAccount(Account account)
 {
     this.unitOfWork.Repository<Account>().Insert(account);
     return account;
 }
コード例 #7
0
 internal void UpdateAccount(Account account)
 {
     account.ObjectState = ObjectState.Modified;
     this.unitOfWork.Repository<Account>().Update(account);
 }
コード例 #8
0
        /// <summary>
        /// <para>Adds an account with a default setting profile and an account admin access code.</para>
        /// </summary>
        /// <param name="description">A short description for the new account.</param>
        /// <param name="subscriptionPlanId">The subscription plan for the new account.</param>
        /// <param name="generatedKey">An out string parameter containing the account admin key or an emptry string on failure.</param>
        /// <param name="newAccountId">An out int parameter containing the new account id or 0 on failure.</param>
        /// <returns>Returns a validation result object.</returns>
        internal IValidationResult AddAccount(string description, int subscriptionPlanId, out string generatedKey, out int newAccountId)
        {
            generatedKey = string.Empty;
            newAccountId = 0;
            IValidationResult validationResult = new ValidationResult();

            // Populate a new account object.
            Account newAccount = new Account();

            // Populate the remaining properties.
            newAccount.Description = description;
            newAccount.DateCreated = DateTime.UtcNow;
            newAccount.LastCredit = DateTime.UtcNow;
            newAccount.LastDebit = DateTime.UtcNow;
            newAccount.Balance = 0;
            newAccount.IsActive = true;
            newAccount.SettingProfileId = 0;
            newAccount.SubscriptionPlanId = subscriptionPlanId;

            // Validate the new account.
            validationResult = this.doctrineShipsValidation.Account(newAccount);
            if (validationResult.IsValid == true)
            {
                // Add the new account and read it back to get the account id.
                newAccount = this.doctrineShipsRepository.CreateAccount(newAccount);
                this.doctrineShipsRepository.Save();

                // Assign the new account id to the passed out parameter.
                newAccountId = newAccount.AccountId;

                // Add a default account admin access code for the account and capture the generated key.
                generatedKey = this.AddAccessCode(newAccount.AccountId, "Default Account Admin", Role.Admin);

                // Create a default setting profile with the new account Id and assign it to the account.
                newAccount.SettingProfileId = this.AddDefaultSettingProfile(newAccount.AccountId);
                this.doctrineShipsRepository.UpdateAccount(newAccount);
                this.doctrineShipsRepository.Save();

                // Log the addition.
                logger.LogMessage("Account '" + newAccount.Description + "' Successfully Added.", 2, "Message", MethodBase.GetCurrentMethod().Name);
            }

            return validationResult;
        }
コード例 #9
0
 public IValidationResult Account(Account account)
 {
     return AccountCheck.Account(account);
 }