Пример #1
0
        /// <summary>
        ///     Deletes the mission.
        /// </summary>
        /// <param name="id">
        ///     The identifier.
        /// </param>
        /// <returns>
        ///     Task{OperationResult}.
        /// </returns>
        public async Task <OperationResult> DeleteMission(string id)
        {
            var entities = await _azureManager.GetEntitiesForCompleteDelete <MissionAzure>(id);

            var    missionAzure = entities.FirstOrDefault(m => m.IsMissionEntity);
            string missionSetId = null;

            if (missionAzure != null)
            {
                missionSetId = missionAzure.MissionSetId;
                await _imagesProvider.DeleteImage(missionAzure.PhotoUrl);
            }

            if (!entities.Any())
            {
                return(new OperationResult(OperationResultStatus.Warning, "No entities to delete"));
            }

            var result = await _azureManager.DeleteEntitiesBatchAsync(entities);

            var refreshResult = await TryRefreshMissionSet(missionSetId);

            if (refreshResult.Status != OperationResultStatus.Success)
            {
                Trace.TraceError(refreshResult.Description);
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        ///     Deletes the question.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>Task{OperationResult}.</returns>
        public async Task <OperationResult> DeleteQuestion(string id)
        {
            var entities = await _azureManager.GetEntitiesForCompleteDelete <QuestionAzure>(id);

            if (entities.Any())
            {
                var result = await _azureManager.DeleteEntitiesBatchAsync(entities);

                return(result);
            }

            return(new OperationResult(OperationResultStatus.Warning, "No entities to delete"));
        }
Пример #3
0
        /// <summary>
        ///     Deletes the missionRequest.
        /// </summary>
        /// <param name="id">
        ///     The identifier.
        /// </param>
        /// <returns>
        ///     Task{OperationResult}.
        /// </returns>
        public async Task <OperationResult> DeleteMissionRequest(string id)
        {
            var entities = await _azureManager.GetEntitiesForCompleteDelete <MissionRequestAzure>(id);

            if (entities.AnyValues())
            {
                var deletingRequest = entities[0];
                var result          = await _azureManager.DeleteEntityAsync(deletingRequest);

                await _imagesProvider.DeleteImages(deletingRequest.ProofImageUrls.SplitStringByDelimiter());

                return(result);
            }

            return(new OperationResult(OperationResultStatus.Warning, "No entities to delete"));
        }
Пример #4
0
        /// <summary>
        ///     Deletes the MissionSet.
        /// </summary>
        /// <param name="id">
        ///     The identifier.
        /// </param>
        /// <returns>
        ///     Task{OperationResult}.
        /// </returns>
        public async Task <OperationResult> DeleteMissionSet(string id)
        {
            var entities = await _azureManager.GetEntitiesForCompleteDelete <MissionSetAzure>(id);

            var missionIds = entities.Where(l => l.IsMissionLink).Select(l => l.MissionId).ToList();

            await ClearBackReference(missionIds);

            if (entities.Any())
            {
                var result = await _azureManager.DeleteEntitiesBatchAsync(entities);

                return(result);
            }

            return(new OperationResult(OperationResultStatus.Warning, "No entities to delete"));
        }
Пример #5
0
        /// <summary>
        /// Deletes the mission draft.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>Task{OperationResult}.</returns>
        public async Task <OperationResult> DeleteMissionDraft(string id)
        {
            var entities = await _azureManager.GetEntitiesForCompleteDelete <MissionDraftAzure>(id);

            var draftAzure = entities.FirstOrDefault(m => !m.IsPersonQualityLink);

            if (draftAzure != null)
            {
                await _imagesProvider.DeleteImage(draftAzure.PhotoUrl);
            }

            if (entities.Any())
            {
                var result = await _azureManager.DeleteEntitiesBatchAsync(entities);

                return(result);
            }

            return(new OperationResult(OperationResultStatus.Warning, "No entities to delete"));
        }