/// <summary> /// Updates the type of the person. /// </summary> /// <param name="personQuality">The mission.</param> /// <returns>Task{OperationResult}.</returns> public async Task <OperationResult> UpdatePersonQuality(PersonQuality personQuality) { var updatedPersonQuality = personQuality.ToAzureModel(); var personQualityAzure = await _azureManager.GetEntityByIdAndRowKeyAsync <PersonQualityAzure>( updatedPersonQuality.PartitionKey, updatedPersonQuality.RowKey); if (personQualityAzure == null) { return(new OperationResult(OperationResultStatus.Error, "No person quality for update")); } updatedPersonQuality.CopyToTableEntity(personQualityAzure); var updateResult = await _azureManager.UpdateEntityAsync(personQualityAzure); if (updateResult.Status == OperationResultStatus.Success) { var warnings = new StringBuilder(); foreach (var personQualityDependent in RepositoriesDependentOnPersonQuality) { var refreshMissionDraftsResult = await personQualityDependent.UpdateLinksToPersonQuality(personQualityAzure.Id, personQualityAzure.Name); if (refreshMissionDraftsResult.Status != OperationResultStatus.Success) { var warning = $"Links to updated person quality are not refreshed in {personQualityDependent.GetType().Name}! "; warnings.AppendLine(warning); } } if (warnings.Length > 0) { return(new OperationResult(OperationResultStatus.Warning, warnings.ToString())); } } return(updateResult); }
/// <summary> /// Adds the type of the person. /// </summary> /// <param name="personQuality">Type of the person.</param> /// <returns>Task{AddResult}.</returns> public async Task <IdResult> AddPersonQuality(PersonQuality personQuality) { personQuality.Id = Guid.NewGuid().ToString("N"); return(await _azureManager.AddEntityAsync(personQuality.ToAzureModel())); }