コード例 #1
0
        public List <ProposalReviewListItemViewModel> GetProposalsByAudienceChannelId(string audienceChannelId)
        {
            string collectionName                   = CosmosCollections.Proposal.ToString();
            string queryGetProposal                 = $"SELECT * FROM {collectionName} WHERE {collectionName}.AudienceChannelId='{audienceChannelId}'";
            List <ProposalDocument> proposals       = context.ExecuteQuery <ProposalDocument>(this.databaseName, CosmosCollections.Proposal.ToString(), queryGetProposal);
            AudienceChannelDocument audienceChannel = _audienceChannelManager.GetAudienceChannelById(audienceChannelId);

            List <ProposalReviewListItemViewModel> results = proposals.Select(p => MapToProposalReviewListItemViewModel(p, audienceChannel)).ToList();

            return(results);
        }
コード例 #2
0
        public bool AddProposal(ProposalViewModel model, string userId)
        {
            bool result = false;

            collectionName = CosmosCollections.Proposal.ToString();

            try
            {
                model.proposal.Id = Guid.NewGuid().ToString();
                model.proposal.AdvertiserProfileId = GetAdvertiserProfile(userId).Id;
                model.proposal.Price = _audienceChannelManager.GetAudienceChannelById(model.proposal.AudienceChannelId).Price;

                if (model.listQuestion != null && model.listQuestion.Any())
                {
                    foreach (var question in model.listQuestion)
                    {
                        model.proposal.Questions.Add(
                            new ProposalAnswerDocument {
                            Id = Guid.NewGuid().ToString(),
                            QuestionAskToAudienceChannelId = question.Id,
                            Question     = question.Question,
                            Answer       = question.Answer,
                            RegisterDate = DateTime.Now.ToString()
                        });
                    }
                }

                context.AddDocument <ProposalDocument>(databaseName, CosmosCollections.Proposal.ToString(), model.proposal);

                result = true;
            }
            catch (Exception e)
            {
                var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(messageException);
            }
            return(result);
        }