public async Task ValidatePickup()
        {
            Status = "PickedUp";
            await Update();

            Contribution contribution = (Contribution)components.Find(x => x is Contribution && x.Status != "Cancelled");
            await contribution.SetStatusPickedUp();
        }
        public async Task ValidateDestination()
        {
            Status        = "Completed";
            TimeCompleted = Utils.UnixTimeSeconds();
            await Update();

            Contribution contribution = (Contribution)components.Find(x => x is Contribution && x.Status != "Cancelled");
            await contribution.SetStatusCompleted();
        }
        public async Task AnswerDeliveryDemand(string deliveryCode, AnswerDeliveryDemandRequest request)
        {
            Status = "InProgress";
            await Update();

            Contribution contribution = new Contribution(ProcessId, Id, deliveryCode, request);

            contribution.SetStore(_transactionStore);
            AddComponent(contribution);
            await contribution.Save();
        }
Example #4
0
        public Process(string campaignId, string campaignName, string campaignUsername, string campaignType, AnswerCampaignRequest request)
        {
            //Process constructor
            Id         = Utils.CreateId();
            CampaignId = campaignId;
            //Initially, a process' status is: Pending
            Status        = "Pending";
            TimeCreated   = Utils.UnixTimeSeconds();
            TimePickedUp  = 0L;
            TimeCompleted = 0L;
            DeliveryCode  = "";
            //A new contribution availabilty gets posted
            Contribution contribution = new Contribution(Id, campaignType, request);

            AddComponent(contribution);

            //A process automatically intiates a new delivery demand if the campaign is a physical donation.
            if (campaignType == "Donation")
            {
                DeliveryDemand deliveryDemand = new DeliveryDemand(Id, campaignName, campaignUsername, request);
                AddComponent(deliveryDemand);
            }
        }