/// <summary> /// Stores or update team tags data in storage. /// </summary> /// <param name="teamCategoryEntity">Represents team tag entity object.</param> /// <returns>A task that represents team tags entity data is saved or updated.</returns> private async Task <TableResult> StoreOrUpdateEntityAsync(TeamCategoryEntity teamCategoryEntity) { await this.EnsureInitializedAsync(); teamCategoryEntity = teamCategoryEntity ?? throw new ArgumentNullException(nameof(teamCategoryEntity)); if (string.IsNullOrWhiteSpace(teamCategoryEntity.Categories) || string.IsNullOrWhiteSpace(teamCategoryEntity.ChannelId)) { return(null); } TableOperation addOrUpdateOperation = TableOperation.InsertOrReplace(teamCategoryEntity); return(await this.CloudTable.ExecuteAsync(addOrUpdateOperation)); }
public async Task <IActionResult> GetAppliedFiltersTeamIdeasAsync(string categories, string sharedByNames, string tags, string sortBy, string teamId, int pageCount) { this.RecordEvent("Ideas - HTTP Get filter ideas call accepted the request."); if (pageCount < 0) { this.logger.LogError($"{pageCount} is less than zero"); return(this.BadRequest($"{nameof(pageCount)} cannot be less than zero.")); } var skipRecords = pageCount * Constants.LazyLoadPerPagePostCount; var teamCategoryEntity = new TeamCategoryEntity(); try { // Team id will be empty when called from personal scope tab. if (!string.IsNullOrEmpty(teamId)) { teamCategoryEntity = await this.teamCategoryStorageProvider.GetTeamCategoriesDataAsync(teamId); } var tagsQuery = string.IsNullOrEmpty(tags) ? "*" : this.ideaStorageHelper.GetTags(tags); categories = string.IsNullOrEmpty(categories) ? teamCategoryEntity.Categories : categories; var filterQuery = this.ideaStorageHelper.GetFilterSearchQuery(categories, sharedByNames); var teamPosts = await this.ideaSearchService.GetTeamIdeasAsync( IdeaSearchScope.FilterTeamPosts, tagsQuery, userObjectId : null, sortBy : sortBy, filterQuery : filterQuery, count : Constants.LazyLoadPerPagePostCount, skip : skipRecords); this.RecordEvent("Team idea applied filters - HTTP Get call succeeded"); return(this.Ok(teamPosts)); } catch (Exception ex) { this.RecordEvent("Team idea applied filters - HTTP Get call failed."); this.logger.LogError(ex, "Error while making call to get ideas as per the applied filters service."); throw; } }
public async Task <IActionResult> PatchAsync([FromBody] TeamCategoryEntity teamCategoryEntity) { this.RecordEvent("Team categories - HTTP PATCH call requested."); try { this.logger.LogInformation("Call to update team category details."); #pragma warning disable CA1062 // teamCategoryEntity is validated by model validations for null check and is responded with bad request status if (string.IsNullOrEmpty(teamCategoryEntity.TeamId)) #pragma warning restore CA1062 // teamCategoryEntity is validated by model validations for null check and is responded with bad request status { this.logger.LogError($"Parameter {nameof(teamCategoryEntity.TeamId)} is found null or empty."); return(this.BadRequest(new { message = $"Parameter {nameof(teamCategoryEntity.TeamId)} is either null or empty." })); } var teamCategoryPreference = await this.teamCategoryStorageProvider.GetTeamCategoriesDataAsync(teamCategoryEntity.TeamId); if (teamCategoryPreference == null) { this.logger.LogError($"Entity for {teamCategoryEntity.TeamId} is not found to update."); this.RecordEvent("Update category - HTTP Patch call failed"); return(this.BadRequest($"An update cannot be performed for {teamCategoryEntity.TeamId} because entity is not available.")); } teamCategoryPreference.Categories = teamCategoryEntity.Categories; teamCategoryPreference.UpdatedByObjectId = this.UserAadId; teamCategoryPreference.UpdatedDate = DateTime.UtcNow; var result = await this.teamCategoryStorageProvider.UpsertTeamCategoriesAsync(teamCategoryPreference); this.RecordEvent("Team categories - HTTP PATCH call succeeded"); return(this.Ok(result)); } catch (Exception ex) { this.logger.LogError(ex, "Error while making call to team category service."); this.RecordEvent("Team categories - HTTP PATCH call failed"); throw; } }
public async Task <IActionResult> PostAsync([FromBody] TeamCategoryEntity teamCategoryEntity) { this.RecordEvent("Team categories - HTTP POST call requested."); try { this.logger.LogInformation("Call to add team category details."); #pragma warning disable CA1062 // teamCategoryEntity is validated by model validations for null check and is responded with bad request status if (string.IsNullOrEmpty(teamCategoryEntity.TeamId)) #pragma warning restore CA1062 // teamCategoryEntity is validated by model validations for null check and is responded with bad request status { this.logger.LogError($"Parameter {nameof(teamCategoryEntity.TeamId)} is found null or empty."); return(this.BadRequest(new { message = $"Parameter {nameof(teamCategoryEntity.TeamId)} is either null or empty." })); } var postEntity = new TeamCategoryEntity() { ChannelId = teamCategoryEntity.TeamId, CreatedByName = this.UserName, CreatedByObjectId = this.UserAadId, CreatedDate = DateTime.UtcNow, Categories = teamCategoryEntity.Categories, TeamId = teamCategoryEntity.TeamId, }; var result = await this.teamCategoryStorageProvider.UpsertTeamCategoriesAsync(postEntity); this.RecordEvent("Team categories - HTTP POST call succeeded"); return(this.Ok(result)); } catch (Exception ex) { this.logger.LogError(ex, "Error while making call to team category service."); this.RecordEvent("Team categories - HTTP POST call failed"); throw; } }
/// <summary> /// Stores or update team tags data in storage. /// </summary> /// <param name="teamCategoryEntity">Represents team tag entity object.</param> /// <returns>A boolean that represents team tags entity is successfully saved/updated or not.</returns> public async Task <bool> UpsertTeamCategoriesAsync(TeamCategoryEntity teamCategoryEntity) { var result = await this.StoreOrUpdateEntityAsync(teamCategoryEntity); return(result.HttpStatusCode == (int)HttpStatusCode.NoContent); }