Esempio n. 1
0
        public List <Account> Get(IQueryable <Account> account, ApplicationStore applicationStore)
        {
            List <Account> result = null;

            if (!account.IsNull())
            {
                if (applicationStore.Application.MemberType == MemberType.Consumer)
                {
                    var _accounts = account.ToList();

                    if (!_accounts.IsNull())
                    {
                        _accounts.ForEach(acc =>
                        {
                            if (lockedUp.Validate(acc, false) &&
                                acc.Status == true &&
                                acc.Removed == false &&
                                (!acc.Document.IsNullOrWhiteSpace() || !acc.Customer.IsNull()))
                            {
                                acc.ConnectApp(applicationStore);
                            }
                        });

                        result = _accounts;
                    }
                }
                else if (applicationStore.Application.AuthType == AuthType.Distributed)
                {
                    result = account.Where(a =>
                                           a.AccountRoles.Any(ar =>
                                                              ar.Status == true &&
                                                              ar.Role.Status == true &&
                                                              ar.Role.StoreCode == applicationStore.StoreCode && ar.Role.Store.Status == true &&
                                                              ar.Role.Permissions.Any(
                                                                  p =>
                                                                  p.Status == true &&
                                                                  p.Resource.ApplicationCode == applicationStore.ApplicationCode &&
                                                                  p.Resource.Application.Status == true
                                                                  )
                                                              )
                                           ).ToList();
                }
                else if (applicationStore.Store.IsMain)
                {
                    result = account.Where(a =>
                                           a.AccountRoles.Any(ar =>
                                                              ar.Status == true &&
                                                              ar.Role.Status == true &&
                                                              ar.Role.Store.Status == true &&
                                                              ar.Role.Permissions.Any(
                                                                  p =>
                                                                  p.Status == true &&
                                                                  p.Resource.ApplicationCode == applicationStore.ApplicationCode &&
                                                                  p.Resource.Application.Status == true
                                                                  )
                                                              )
                                           ).ToList();
                }
            }

            return(result);
        }