Пример #1
0
        public AccessResultModel DetermineAccessResults(string username)
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentNullException();
            }

            var userData        = this._userDataRetrieval.RetrieveUserDetails(username);
            var membershipTypes = this._configurationRetrieval.RetrieveMembershipTypes();
            var userMembership  = membershipTypes.FirstOrDefault(p => p.MembershipTypeName.Equals(userData.MembershipTypeName, StringComparison.OrdinalIgnoreCase));

            var result = new AccessResultModel();

            if (userMembership != null)
            {
                result.CanApply  = userData.CurrentUsage.CurrentApplicationsCount < userMembership.Restriction.MaxApplicationsPerDay ? true : false;
                result.CanSearch = userData.CurrentUsage.CurrentSearchesCount < userMembership.Restriction.MaxSearchesPerDay ? true : false;
            }

            return(result);
        }