Esempio n. 1
0
        public OfferProposal SaveOfferProposal(string receivingSubscriptionId, string sendingSubscriptionId, Offer offer, string demandId = null, Proposal.StateEnum state = Proposal.StateEnum.InitialEnum)
        {
            if (this.SubscriptionProposals.ContainsKey(receivingSubscriptionId) && this.Subscriptions[receivingSubscriptionId] is DemandSubscription)
            {
                var offerProposal = new OfferProposal()
                {
                    Id         = "" + Guid.NewGuid(),
                    InternalId = this.GetNextProposalInternalId(),
                    ReceivingSubscriptionId = receivingSubscriptionId,
                    SendingSubscriptionId   = sendingSubscriptionId,
                    DemandId = demandId,
                    Offer    = offer,
                    State    = state
                };

                this.SubscriptionProposals[receivingSubscriptionId].Add(offerProposal);
                this.OfferProposals[offerProposal.Id] = offerProposal;

                return(offerProposal);
            }
            else
            {
                throw new Exception($"Demand Subscription Id {receivingSubscriptionId} does not exist!");
            }
        }
Esempio n. 2
0
        public DemandProposal SaveDemandProposal(string receivingSubscriptionId, string sendingSubscriptionId, Demand demand, string offerId = null, Proposal.StateEnum state = Proposal.StateEnum.InitialEnum)
        {
            if (this.SubscriptionProposals.ContainsKey(receivingSubscriptionId) && this.Subscriptions[receivingSubscriptionId] is OfferSubscription)
            {
                var demandProposal = new DemandProposal()
                {
                    Id         = "" + Guid.NewGuid(),
                    InternalId = this.GetNextProposalInternalId(),
                    ReceivingSubscriptionId = receivingSubscriptionId,
                    SendingSubscriptionId   = sendingSubscriptionId,
                    OfferId = offerId,
                    Demand  = demand,
                    State   = state
                };

                // TODO do we need a lock here???
                this.SubscriptionProposals[receivingSubscriptionId].Add(demandProposal);
                this.DemandProposals[demandProposal.Id] = demandProposal;

                return(demandProposal);
            }
            else
            {
                throw new Exception($"Offer Subscription Id {receivingSubscriptionId} does not exist!");
            }
        }