/// <summary> /// Asynchronously checks the URL uniqness. /// </summary> /// <param name="url">The URL.</param> /// <returns>True if url is unique</returns> public virtual async Task <bool> IsUrlUniqueAsync(string url) { try { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(string.Format("{0}/unique/url", ModuleRelativePath), url)); InitializeQueryStringPair(uriBuilder, "url", url); await client.GetAsync <bool>(uriBuilder.ToString()); return(true); } } catch (BaasicClientException ex) { if (ex.ErrorCode == (int)HttpStatusCode.Conflict) { return(false); } throw; } catch (Exception) { throw; } }
/// <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); } }
/// <summary> /// Asynchronously gets the <see cref="KeyValue" /> by provided key. /// </summary> /// <param name="key">Key.</param> /// <returns><see cref="KeyValue" /> .</returns> public virtual Task <KeyValue> GetAsync(object key) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { return(client.GetAsync <KeyValue>(client.GetApiUrl(String.Format("{0}/{{0}}", ModuleRelativePath), key))); } }
/// <summary> /// Asynchronously gets the <see cref="Navigation" /> from the system. /// </summary> /// <typeparam name="T">Type of extended <see cref="Navigation" />.</typeparam> /// <param name="id">The 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 Task <T> GetAsync <T>(object id, string embed = DefaultEmbed, string fields = DefaultFields) where T : Navigation { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/{{0}}", ModuleRelativePath), id)); InitializeQueryString(uriBuilder, embed, fields); return(client.GetAsync <T>(uriBuilder.ToString())); } }
/// <summary> /// Asynchronously gets the <see cref="T" /> by provided key. /// </summary> /// <param name="id">The identifier.</param> /// <param name="schemaName">The schema name.</param> /// <param name="embed">The embed.</param> /// <param name="fields">The fields to include in response.</param> /// <returns><see cref="T" /> .</returns> public virtual Task <T> GetAsync(string schemaName, SGuid id, string embed = ClientBase.DefaultEmbed, string fields = ClientBase.DefaultFields) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/{1}/{{0}}", ModuleRelativePath, schemaName), id)); InitializeQueryString(uriBuilder, embed, fields); return(client.GetAsync <T>(uriBuilder.ToString())); } }
/// <summary> /// Asynchronously gets the <see cref="FileEntry" /> from the system. /// </summary> /// <typeparam name="T">Type of extended <see cref="FileEntry" />.</typeparam> /// <param name="id">The identifier.</param> /// <param name="width">The file width.</param> /// <param name="height">The file height.</param> /// <returns>If found <typeparamref name="T" /> is returned, otherwise null.</returns> public virtual Task <Stream> GetFileAsync(object id, int?width = null, int?height = null) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/{{0}}", ModuleRelativePath), id)); InitializeQueryStringPair(uriBuilder, "width", width); InitializeQueryStringPair(uriBuilder, "height", height); return(client.GetAsync(uriBuilder.ToString())); } }
/// <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); } }
/// <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); } }
/// <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); } }