private async void AnswerDonationCampaignAsync(object sender, EventArgs e) { long timeWindowStart; long timeWindowEnd; if (DonationInfoPanel_Checkbox.Checked) { timeWindowStart = 0L; timeWindowEnd = 9999999999; } else { timeWindowStart = ToUnixTime(DonationInfoPanel_DatePicker.Value, DonationInfoPanel_TimePicker1.Value); timeWindowEnd = ToUnixTime(DonationInfoPanel_DatePicker.Value, DonationInfoPanel_TimePicker2.Value); } var answerCampaignRequest = new AnswerCampaignRequest { Username = Properties.Settings.Default["Username"].ToString(), TimeWindowStart = timeWindowStart, TimeWindowEnd = timeWindowEnd, OtherInfo = DonationInfoPanel_OtherInfo.Text }; await client.AnswerCampaign(matchedCampaign.Id, answerCampaignRequest); MessageBox.Show("Thank you for your donation! Please wait until a volunteer picks it up. Meanwhile, you can check the status of your contribution in \"My Contributions\"."); Navigate(MenuPanel); }
public async Task AnswerCampaign(AnswerCampaignRequest request) { //update the campaign with info (In the process when everything is done) //Add a new process Process process = new Process(Id, Name, Username, Type, request); process.SetStore(_transactionStore); AddComponent(process); await process.Save(); }
public async Task AnswerCampaign(string campaignId, AnswerCampaignRequest answerCampaignRequest) { string json = JsonConvert.SerializeObject(answerCampaignRequest); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"api/transactions/campaigns/answer-campaign/{campaignId}") { Content = new StringContent(json, Encoding.UTF8, "application/json") }; HttpResponseMessage responseMessage = await _httpClient.SendAsync(request); await EnsureSuccessOrThrowAsync(responseMessage); }
private async void VolunteeringCampaignMatchPanel_ContributeButton_Click(object sender, EventArgs e) { var answerCampaignRequest = new AnswerCampaignRequest { Username = Properties.Settings.Default["Username"].ToString(), OtherInfo = VolunteeringInfoPanel_OtherInfo.Text }; await client.AnswerCampaign(matchedCampaign.Id, answerCampaignRequest); MessageBox.Show("Thank you for your initiative! Please wait until the NGOs accepts your volunteering request. Meanwhile, you can check the status of your contribution in \"My Contributions\". "); Navigate(MenuPanel); }
public Contribution(string processId, string campaignType, AnswerCampaignRequest request) { Id = Utils.CreateId(); ProcessId = processId; Type = campaignType; Username = request.Username; Status = "Pending"; TimeWindowStart = request.TimeWindowStart; TimeWindowEnd = request.TimeWindowEnd; OtherInfo = request.OtherInfo; TimeCreated = Utils.UnixTimeSeconds(); TimeCompleted = 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); } }
public async Task <IActionResult> AnswerCampaign(string campaignId, [FromBody] AnswerCampaignRequest request) { await _transactionService.AnswerCampaign(campaignId, request); return(Ok()); }
public DeliveryDemand(string processId, string campaignName, string campaignUsername, AnswerCampaignRequest request) { Id = Utils.CreateId(); ProcessId = processId; CampaignName = campaignName; PickupUsername = request.Username; DestinationUsername = campaignUsername; Status = "Pending"; TimeWindowStart = request.TimeWindowStart; TimeWindowEnd = request.TimeWindowEnd; OtherInfo = request.OtherInfo; TimeCreated = Utils.UnixTimeSeconds(); TimeCompleted = 0; }
public async Task AnswerCampaign(string campaignId, AnswerCampaignRequest request) { Campaign campaign = await BuildCampaign(campaignId); await campaign.AnswerCampaign(request); }