public BusinessIdentityData Fetch(BusinessIdentityDataCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                              .GetManager(Database.SecurityConnection, false))
            {
                IQueryable<User> query = ctx.ObjectContext.Users;

                query = query.Where(row => row.Name == criteria.Name);

                var users = query.Select(row => row);

                if (users.Count() == 0)
                {
                    return null;
                }

                var user = users.Single();

                var data = new BusinessIdentityData();

                this.Fetch(user, data);

                return data;
            }
        }
        public BusinessIdentityData Fetch(BusinessIdentityDataCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.SecurityConnection, false))
            {
                IQueryable <User> query = ctx.ObjectContext.Users;

                query = query.Where(row => row.Name == criteria.Name);

                var users = query.Select(row => row);

                if (users.Count() == 0)
                {
                    return(null);
                }

                var user = users.Single();

                var data = new BusinessIdentityData();

                this.Fetch(user, data);

                return(data);
            }
        }
        public BusinessIdentityData Fetch(BusinessIdentityDataCriteria criteria)
        {
            var data = MockDb.Users
                .Where(row => row.Name == criteria.Name)
                .SingleOrDefault();

            var result = new BusinessIdentityData();

            result.UserId = data.UserId;
            result.Email = data.Email;
            result.Name = data.Name;
            result.FullName = data.FullName;
            result.Password = data.Password;
            result.Salt = data.Salt;

            return result;
        }
        public BusinessIdentityData Fetch(BusinessIdentityDataCriteria criteria)
        {
            var data = MockDb.Users
                       .Where(row => row.Name == criteria.Name)
                       .SingleOrDefault();

            var result = new BusinessIdentityData();

            result.UserId   = data.UserId;
            result.Email    = data.Email;
            result.Name     = data.Name;
            result.FullName = data.FullName;
            result.Password = data.Password;
            result.Salt     = data.Salt;

            return(result);
        }
        private void DataPortal_Fetch(BusinessIdentityDataCriteria criteria)
        {
            using (var dalManager = DataFactoryManager.GetManager())
            {
                var dalFactory = dalManager.GetProvider <IBusinessIdentityDataFactory>();

                var data = dalFactory.Fetch(criteria);

                if (data == null)
                {
                    throw new InvalidUserException();
                }

                if (!string.IsNullOrEmpty(criteria.Password))
                {
                    if (!PasswordHelper.ComparePasswords(data.Salt, criteria.Password, data.Password))
                    {
                        throw new InvalidPasswordException();
                    }
                }

                this.Fetch(data);
            }
        }
        private void DataPortal_Fetch(BusinessIdentityDataCriteria criteria)
        {
            using (var dalManager = DataFactoryManager.GetManager())
            {
                var dalFactory = dalManager.GetProvider<IBusinessIdentityDataFactory>();

                var data = dalFactory.Fetch(criteria);

                if (data == null)
                {
                    throw new InvalidUserException();
                }

                if (!string.IsNullOrEmpty(criteria.Password))
                {
                    if (!PasswordHelper.ComparePasswords(data.Salt, criteria.Password, data.Password))
                    {
                        throw new InvalidPasswordException();
                    }
                }

                this.Fetch(data);
            }
        }