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;
        }
 public void UpdateAccount(Account account)
 {
     AccountOperations.UpdateAccount(account);
 }
 public Account CreateAccount(Account account)
 {
     return AccountOperations.CreateAccount(account);
 }
 public Account AddAccount(Account account)
 {
     return AccountOperations.AddAccount(account);
 }
 internal Account CreateAccount(Account account)
 {
     account.ObjectState = ObjectState.Added;
     this.unitOfWork.Repository<Account>().Insert(account);
     return account;
 }
 internal Account AddAccount(Account account)
 {
     this.unitOfWork.Repository<Account>().Insert(account);
     return account;
 }
 internal void UpdateAccount(Account account)
 {
     account.ObjectState = ObjectState.Modified;
     this.unitOfWork.Repository<Account>().Update(account);
 }
        /// <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;
        }
 public IValidationResult Account(Account account)
 {
     return AccountCheck.Account(account);
 }