Ejemplo n.º 1
0
        public static async Task <bool> PostConfirmDonation(ConfirmDonation req)
        {
            try
            {
                var client   = new HttpClient();
                var json     = JsonConvert.SerializeObject(req);
                var content  = new StringContent(json, Encoding.UTF8, "application/json");
                var response = await client.PostAsync($"{postdonationreqUrl}?txnref={req.orderID}", content);

                if (!response.IsSuccessStatusCode)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception er)
            {
                return(false);
            }
        }
        // ================== deliver donation ==============
        public ActionResult DeliveredDonationByVolunteer(ConfirmDonation model)
        {
            string item_id = model.item_id;

            Debug.WriteLine(item_id);
            Debug.WriteLine("i'm triggering");
            try
            {
                firebaseClient = new FireSharp.FirebaseClient(firebaseConfig);

                if (model.item_type == "food")
                {
                    FirebaseResponse response = firebaseClient.Get("FoodDonation/" + item_id);
                    FoodDonation     data     = JsonConvert.DeserializeObject <FoodDonation>(response.Body);
                    UpdateFoodDeliveredStatus(data);
                }
                else if (model.item_type == "cloth")
                {
                    FirebaseResponse response = firebaseClient.Get("ClothDonation/" + item_id);
                    ClothDonation    data     = JsonConvert.DeserializeObject <ClothDonation>(response.Body);
                    UpdateClothDeliveredStatus(data);
                }
                else if (model.item_type == "money")
                {
                    FirebaseResponse response = firebaseClient.Get("MoneyDonation/" + item_id);
                    MoneyDonation    data     = JsonConvert.DeserializeObject <MoneyDonation>(response.Body);
                    UpdateMoneyDeliveredStatus(data);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception from Food Donation confirmation: " + ex);
            }

            return(RedirectToAction("/Index2"));
        }