Пример #1
0
        /// <summary>
        ///     Adds the mission.
        /// </summary>
        /// <param name="mission">
        ///     The mission.
        /// </param>
        /// <returns>
        ///     Task{AddResult}.
        /// </returns>
        public async Task <IdResult> AddMission(Mission mission)
        {
            mission.Id = Guid.NewGuid().ToString("N");
            var azureModel = mission.ToAzureModel();

            azureModel.PhotoUrl =
                await _imagesProvider.SaveImageToProductionBlobOnAdd(azureModel.PhotoUrl, BlobContainer.MissionImages);

            var typeLinks = GeneratePersonQualityLinks(mission);

            var batch = new List <MissionAzure> {
                azureModel
            };

            if (typeLinks.Any())
            {
                batch.AddRange(typeLinks);
            }

            var hints = GenerateHintLinks(mission);

            if (hints.Any())
            {
                batch.AddRange(hints);
            }
            // Currently setting mission to MissionSet on Add is impossible and seems not required.
            return(await _azureManager.AddEntityBatchAsync(batch));
        }
Пример #2
0
        /// <summary>
        ///     Adds user after adding identity. Id generation doesn't happen.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>The <see cref="Task" />.</returns>
        public async Task <IdResult> AddUser(User user)
        {
            var azureModel = user.ToAzureModel();
            var typeLinks  = GeneratePersonQualityLinks(user);

            var batch = new List <UserAzure> {
                azureModel
            };

            if (typeLinks.Any())
            {
                batch.AddRange(typeLinks);
            }

            return(await _azureManager.AddEntityBatchAsync(batch));
        }
Пример #3
0
        /// <summary>
        ///     Adds the mission draft.
        /// </summary>
        /// <param name="mission">
        ///     The mission.
        /// </param>
        /// <returns>
        ///     Task{AddResult}.
        /// </returns>
        public async Task <IdResult> AddMissionDraft(MissionDraft mission)
        {
            mission.Id = Guid.NewGuid().ToString();
            var missionDraft = mission.ToAzureModel();
            var typeLinks    = GeneratePersonQualityLinks(mission);

            missionDraft.PhotoUrl = await _imagesProvider.SaveImageToProductionBlobOnAdd(missionDraft.PhotoUrl, BlobContainer.MissionDraftImages);

            if (!typeLinks.Any())
            {
                return(await _azureManager.AddEntityAsync(missionDraft));
            }

            typeLinks.Insert(0, missionDraft);
            return(await _azureManager.AddEntityBatchAsync(typeLinks));
        }
Пример #4
0
        /// <summary>
        ///     Adds the MissionSet.
        /// </summary>
        /// <param name="missionSet">
        ///     The MissionSet.
        /// </param>
        /// <returns>
        ///     Task{AddResult}.
        /// </returns>
        public async Task <IdResult> AddMissionSet(MissionSet missionSet)
        {
            missionSet.Id = Guid.NewGuid().ToString("N");
            var azureModel   = missionSet.ToAzureModel();
            var missionLinks = await GenerateMissionDependentLinks(missionSet, azureModel);

            var batch = new List <MissionSetAzure> {
                azureModel
            };

            if (missionLinks.Any())
            {
                batch.AddRange(missionLinks);
            }

            return(await _azureManager.AddEntityBatchAsync(batch));
        }
Пример #5
0
        /// <summary>
        ///     Adds the question.
        /// </summary>
        /// <param name="question">The question.</param>
        /// <returns>Task{AddResult}.</returns>
        public async Task <IdResult> AddQuestion(Question question)
        {
            question.Id = Guid.NewGuid().ToString("N");
            var azureModel = question.ToAzureModel();
            var options    = GenerateOptions(question);

            var batch = new List <QuestionAzure> {
                azureModel
            };

            if (options.Any())
            {
                batch.AddRange(options);
            }

            return(await _azureManager.AddEntityBatchAsync(batch));
        }