diff --git a/Controller/XWebinarServiceControllerBase.cs b/Controller/XWebinarServiceControllerBase.cs index 5d15acc..4ea7593 100644 --- a/Controller/XWebinarServiceControllerBase.cs +++ b/Controller/XWebinarServiceControllerBase.cs @@ -192,6 +192,33 @@ namespace xWebinarService.Controller } } + /// + /// Retrieve all Exists Webinar Ids ... + /// + /// + [HttpGet("Ids")] + public virtual async Task>> GetWebinarIds() + { + // + // Do ... + try + { + // + var result = await WebinarProvider + .GetWebinarIds(); + + // + return Ok(result. + ToDynamicObject()); + } + catch (Exception ex) + { + // + var result = GetExceptionActionResult(ex); + return result; + } + } + /// /// Query Webinars ... /// @@ -222,6 +249,36 @@ namespace xWebinarService.Controller } } + /// + /// Query Webinar Ids ... + /// + /// + /// + [HttpGet("QueryIds")] + public virtual async Task>> QueryWebinarIds( + [FromQuery] XQuery query + ) + { + // + // Do ... + try + { + // + var result = await WebinarProvider + .QueryWebinarIds(query); + + // + return Ok(result. + ToDynamicObject()); + } + catch (Exception ex) + { + // + var result = GetExceptionActionResult(ex); + return result; + } + } + /// /// Remove Specified Webinar ... /// diff --git a/Interfaces/IXWebinarProvider.cs b/Interfaces/IXWebinarProvider.cs index fa8ce08..7be2097 100644 --- a/Interfaces/IXWebinarProvider.cs +++ b/Interfaces/IXWebinarProvider.cs @@ -63,6 +63,12 @@ namespace xWebinarService.Interfaces /// Task GetWebinar(Guid id); + /// + /// Retrieve all Exists Webinar Ids ... + /// + /// + Task> GetWebinarIds(); + /// /// Retrieve all Exists Webinars ... /// @@ -76,6 +82,13 @@ namespace xWebinarService.Interfaces /// Task> QueryWebinars(XQuery query); + /// + /// Query Webinar Ids ... + /// + /// + /// + Task> QueryWebinarIds(XQuery query); + /// /// Remove Specified Webinar ... /// diff --git a/Interfaces/IXWebinarServiceControllerActions.cs b/Interfaces/IXWebinarServiceControllerActions.cs index a10f26c..d8bcb5a 100644 --- a/Interfaces/IXWebinarServiceControllerActions.cs +++ b/Interfaces/IXWebinarServiceControllerActions.cs @@ -41,6 +41,12 @@ namespace xWebinarService.Interfaces /// Task>> GetWebinars(); + /// + /// Retrieve all Exists Webinar Ids ... + /// + /// + Task>> GetWebinarIds(); + /// /// Query Webinars ... /// @@ -48,6 +54,13 @@ namespace xWebinarService.Interfaces /// Task>> QueryWebinars([FromQuery] XQuery query); + /// + /// Query Webinar Ids ... + /// + /// + /// + Task>> QueryWebinarIds([FromQuery] XQuery query); + /// /// Remove Specified Webinar ... /// diff --git a/Providers/XWebinarProvider.cs b/Providers/XWebinarProvider.cs index 69f9ebb..a817409 100644 --- a/Providers/XWebinarProvider.cs +++ b/Providers/XWebinarProvider.cs @@ -391,14 +391,14 @@ namespace xWebinarService.Providers // Title ... var titleAddedLocales = await TitleResourceProvider.AddOrUpdate( resource: entity.Title, - locales: entityDto.Title.Locales + locales: item.Title.Locales ); // // Description ... var descriptionAddedLocales = await DescriptionResourceProvider.AddOrUpdate( resource: entity.Description, - locales: entityDto.Description.Locales + locales: item.Description.Locales ); // @@ -441,6 +441,19 @@ namespace xWebinarService.Providers return result; } + /// + /// Retrieve all Exists Webinar Ids ... + /// + /// + public async Task> GetWebinarIds() + { + // + var result = await WebinarRepository.AsQueryable().SelectAsync(async l => l.Id); + + // + return result; + } + /// /// Query Webinars ... /// @@ -518,6 +531,75 @@ namespace xWebinarService.Providers return result; } + /// + /// Query Webinar Ids ... + /// + /// + /// + public async Task> QueryWebinarIds(XQuery query) + { + // + // Validate ... + if (query.IsNull()) + { + XException.InvalidArgs.Throw(); + } + + // + // Normalize ... + query = query.NormalizeQuery(DataSercviceConfiguration); + + // + // Since in Resourceable Entities we have to Search on Locales + // we Must Implement Senario Custom ... + var items = await GetWebinarIds(); + var totalItemsCount = items.Count(); + + // + // Apply Filter ... + if (!query.Filter.IsNullOrEmpty()) + { + // + items = items + .Where(i => i.ToString().ToNormalString().Contains(query.Filter)); + } + int filteredItemsCount = items.Count(); + + // + // Count Pages ... + var totalPagesCount = query.CountPages(totalItemsCount); + var filteredPagesCount = query.CountPages(filteredItemsCount); + + // + // Apply Paging and Sorting ... + if (totalItemsCount > 0 && + filteredItemsCount > 0) + { + // + // Apply Paging ... + items = items.ApplyPaging( + query.Page, + query.PageSize + ); + } + + // + // Prepare Result ... + var result = new XQueryResult + { + Items = items, + Page = query.Page, + PageSize = query.PageSize, + TotalPages = totalPagesCount, + TotalItems = totalItemsCount, + TotalFilteredPages = filteredPagesCount, + TotalFilteredItems = filteredItemsCount + }; + + // + return result; + } + /// /// Remove Specified Webinar ... ///