コード例 #1
0
        /// <summary>
        /// Get an array of contacts within the specified filters.
        /// Note that the 'contactFilter' will control the 'page' and 'quantity'.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public IEnumerable <PimsContactMgrVw> Get(ContactFilter filter)
        {
            this.User.ThrowIfNotAuthorized(Permissions.ContactView);
            filter.ThrowIfNull(nameof(filter));
            if (!filter.IsValid())
            {
                throw new ArgumentException("Argument must have a valid filter", nameof(filter));
            }

            IEnumerable <PimsContactMgrVw> contacts = this.Context.GenerateContactQuery(filter).ToArray();

            return(contacts);
        }
コード例 #2
0
        /// <summary>
        /// Get a page with an array of contacts within the specified filters.
        /// Note that the 'contactFilter' will control the 'page' and 'quantity'.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public Paged <PimsContactMgrVw> GetPage(ContactFilter filter)
        {
            this.User.ThrowIfNotAuthorized(Permissions.ContactView);
            filter.ThrowIfNull(nameof(filter));
            if (!filter.IsValid())
            {
                throw new ArgumentException("Argument must have a valid filter", nameof(filter));
            }

            var skip  = (filter.Page - 1) * filter.Quantity;
            var query = this.Context.GenerateContactQuery(filter);
            var items = query
                        .Skip(skip)
                        .Take(filter.Quantity)
                        .ToArray();

            return(new Paged <PimsContactMgrVw>(items, filter.Page, filter.Quantity, query.Count()));
        }