Exemplo n.º 1
0
        /// <summary>
        /// Asynchronously find <see cref="Navigation" /> s.
        /// </summary>
        /// <typeparam name="T">Type of extended <see cref="Navigation" />.</typeparam>
        /// <param name="searchQuery">Search query.</param>
        /// <param name="from">The form date.</param>
        /// <param name="to">The to date.</param>
        /// <param name="ids">The file ids.</param>
        /// <param name="url">The url.</param>
        /// <param name="menuId">The menu id.</param>
        /// <param name="pageIds">The page ids.</param>
        /// <param name="page">Page number.</param>
        /// <param name="rpp">Records per page limit.</param>
        /// <param name="sort">Sort by field.</param>
        /// <param name="embed">Embed related resources.</param>
        /// <param name="fields">The fields to include in response.</param>
        /// <returns>Collection of <typeparamref name="T" /> s.</returns>
        public virtual async Task <CollectionModelBase <T> > FindAsync <T>(string searchQuery = DefaultSearchQuery,
                                                                           DateTime?from      = null, DateTime?to            = null, string ids     = null,
                                                                           string url         = null, string menuId          = null, string pageIds = null,
                                                                           int page           = DefaultPage, int rpp         = DefaultMaxNumberOfResults,
                                                                           string sort        = DefaultSorting, string embed = DefaultEmbed, string fields = DefaultFields)
            where T : Navigation
        {
            using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
            {
                UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(ModuleRelativePath));
                InitializeQueryString(uriBuilder, searchQuery, page, rpp, sort, embed, fields);
                InitializeQueryStringPair(uriBuilder, "from", from);
                InitializeQueryStringPair(uriBuilder, "to", to);
                InitializeQueryStringPair(uriBuilder, "ids", ids);
                InitializeQueryStringPair(uriBuilder, "url", url);
                InitializeQueryStringPair(uriBuilder, "menuId", menuId);
                InitializeQueryStringPair(uriBuilder, "pageIds", pageIds);
                var result = await client.GetAsync <CollectionModelBase <T> >(uriBuilder.ToString());

                if (result == null)
                {
                    result = new CollectionModelBase <T>();
                }
                return(result);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Asynchronously gets the collection of <see cref="Navigation" /> from the system ordered in a tree structure.
        /// </summary>
        /// <typeparam name="T">Type of extended <see cref="Navigation" />.</typeparam>
        /// <param name="menuId">The <see cref="Menu" /> identifier.</param>
        /// <param name="embed">Embed related resources.</param>
        /// <param name="fields">The fields to include in response.</param>
        /// <returns>If found <typeparamref name="T" /> is returned, otherwise null.</returns>
        public virtual async Task <CollectionModelBase <T> > GetTreeAsync <T>(object menuId, string embed = DefaultEmbed, string fields = DefaultFields) where T : Navigation
        {
            using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
            {
                UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/tree/{{0}}", ModuleRelativePath), menuId));
                InitializeQueryString(uriBuilder, embed, fields);
                var result = await client.GetAsync <CollectionModelBase <T> >(uriBuilder.ToString());

                if (result == null)
                {
                    result = new CollectionModelBase <T>();
                }
                return(result);
            }
        }
        /// <summary>
        /// Asynchronously find <see cref="T" /> s.
        /// </summary>
        /// <param name="schemaName">The schema name.</param>
        /// <param name="searchQuery">Search query.</param>
        /// <param name="page">Page number.</param>
        /// <param name="rpp">Records per page limit.</param>
        /// <param name="sort">Sort by field.</param>
        /// <param name="embed">Embed related resources.</param>
        /// <param name="fields">The fields to include in response.</param>
        /// <returns>List of <see cref="T" /> s.</returns>
        public virtual async Task <CollectionModelBase <T> > FindAsync(string schemaName, string searchQuery = ClientBase.DefaultSearchQuery, int page = ClientBase.DefaultPage, int rpp = ClientBase.DefaultMaxNumberOfResults, string sort = ClientBase.DefaultSorting, string embed = ClientBase.DefaultEmbed, string fields = ClientBase.DefaultFields)
        {
            using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
            {
                UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl("{0}/{1}", ModuleRelativePath, schemaName));
                InitializeQueryString(uriBuilder, searchQuery, page, rpp, sort, embed, fields);
                CollectionModelBase <T> result = await client.GetAsync <CollectionModelBase <T> >(uriBuilder.ToString());

                if (result == null)
                {
                    result = new CollectionModelBase <T>();
                }
                return(result);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Asynchronously gets the collection of <see cref="Navigation" /> from the system ordered in a tree structure.
        /// </summary>
        /// <typeparam name="T">Type of extended <see cref="Navigation" />.</typeparam>
        /// <param name="position">The position of <see cref="Menu" /></param>
        /// <param name="languageId">The <see cref="Menu" /> language.</param>
        /// <param name="embed">Embed related resources.</param>
        /// <param name="fields">The fields to include in response.</param>
        /// <returns>If found <typeparamref name="T" /> is returned, otherwise null.</returns>
        public virtual async Task <CollectionModelBase <T> > GetTreeAsync <T>(string position, object languageId = null, string embed = ClientBase.DefaultEmbed, string fields = ClientBase.DefaultFields) where T : Navigation
        {
            using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
            {
                UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/tree", ModuleRelativePath)));
                InitializeQueryString(uriBuilder, embed, fields);
                InitializeQueryStringPair(uriBuilder, "position", position);
                InitializeQueryStringPair(uriBuilder, "languageId", languageId);
                var result = await client.GetAsync <CollectionModelBase <T> >(uriBuilder.ToString());

                if (result == null)
                {
                    result = new CollectionModelBase <T>();
                }
                return(result);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Asynchronously find <see cref="UserProfile" /> s.
        /// </summary>
        /// <typeparam name="T">Type of extended <see cref="UserProfile" />.</typeparam>
        /// <param name="searchQuery">Search query.</param>
        /// <param name="page">Page number.</param>
        /// <param name="rpp">Records per page limit.</param>
        /// <param name="sort">Sort by field.</param>
        /// <param name="embed">Embed related resources.</param>
        /// <param name="fields">The fields to include in response.</param>
        /// <returns>List of <typeparamref name="T" /> s.</returns>
        public virtual async Task <CollectionModelBase <T> > FindAsync <T>(string searchQuery = DefaultSearchQuery,
                                                                           int page           = DefaultPage, int rpp         = DefaultMaxNumberOfResults,
                                                                           string sort        = DefaultSorting, string embed = DefaultEmbed, string fields = DefaultFields) where T : UserProfile
        {
            using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
            {
                UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(ModuleRelativePath));
                InitializeQueryString(uriBuilder, searchQuery, page, rpp, sort, embed, fields);
                var result = await client.GetAsync <CollectionModelBase <T> >(uriBuilder.ToString());

                if (result == null)
                {
                    result = new CollectionModelBase <T>();
                }
                return(result);
            }
        }