Ejemplo n.º 1
0
        private void LoadAccounts()
        {
            userSelectedValue = string.IsNullOrEmpty(ddlClient.SelectedValue) ? -1 : Convert.ToInt32(ddlClient.SelectedValue);

            if (userSelectedValue != -1)
            {
                var client          = Provider.Data.Client.GetClient(userSelectedValue);
                var accts           = Provider.Data.Client.GetActiveAccounts(client.ClientID, PeriodPicker1.SelectedPeriod, PeriodPicker1.SelectedPeriod.AddMonths(1)).ToList();
                var util            = new ClientPreferenceUtility(Provider);
                var orderedAccounts = util.OrderAccountsByUserPreference(client, accts);
                if (orderedAccounts != null)
                {
                    ddlAccount.DataSource = orderedAccounts.Select(x => new { AccountName = x.FullAccountName, AccountID = x.AccountID.ToString() });
                    ddlAccount.DataBind();
                }
            }
            else
            {
                ddlAccount.Items.Clear();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads Reservation Billing Account Dropdownlist
        /// </summary>
        public bool LoadAccounts(List <IClientAccount> accts, ActivityAccountType acctType, IClient client, IEnumerable <Invitee> invitees, string username)
        {
            bool mustAddInvitee = false;

            //IList<ClientAccountItem> activeAccounts = new List<ClientAccountItem>();
            IEnumerable <IClientAccount> activeAccounts = new List <IClientAccount>();

            if (acctType == ActivityAccountType.Reserver || acctType == ActivityAccountType.Both)
            {
                /// Loads reserver's accounts
                activeAccounts = Provider.Data.Client.GetActiveClientAccounts(username);
            }

            if (acctType == ActivityAccountType.Invitee || acctType == ActivityAccountType.Both)
            {
                // Loads each of the invitee's accounts

                if (invitees != null)
                {
                    var invited = invitees.Where(x => !x.Removed).ToList();

                    if (invited.Count > 0)
                    {
                        var inviteeClientIds = invited.Select(x => x.InviteeID).ToArray();
                        activeAccounts = Provider.Data.Client.GetActiveClientAccounts(inviteeClientIds);
                    }
                    else
                    {
                        mustAddInvitee = true;
                    }
                }
            }

            var orderedAccts = ClientPreferenceUtility.OrderListByUserPreference(client, activeAccounts, x => x.AccountID, x => x.AccountName);

            accts.AddRange(orderedAccts);

            return(mustAddInvitee);
        }