private async Task <bool> PostAllRequests(string status, string statusText, List <DiscountDetailsModel> discountList)
        {
            try
            {
                foreach (var item in discountList)
                {
                    DiscountPayload discountPayload = new DiscountPayload();
                    discountPayload.ImHotelId       = Constants._hotel_number;
                    discountPayload.ImReservaId     = Convert.ToInt32(item.ReservationID).ToString();
                    discountPayload.ImOrderId       = "1";
                    discountPayload.ImScoodApprover = Settings.Username;
                    discountPayload.ImStatus        = status;
                    discountPayload.ImReason        = $"{statusText} by {Settings.Username}";


                    var responce = await POSTServicesAPI.ApproveDiscount(discountPayload);

                    if (responce == "Success")
                    {
                        continue;
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #2
0
        public static async Task <string> ApproveDiscount(DiscountPayload payload)
        {
            string url    = "beta/v1/approvadiscount/";
            string result = await GetODataService(url, JsonConvert.SerializeObject(payload));

            //If result is success
            if (result == "success")
            {
                return("Success");
            }
            else if (result == "Error")
            {
                return("Sorry");
            }
            else
            {
                return("Sorry");
            }
        }
        private async void RejectDiscount()
        {
            var responce = await Application.Current.MainPage.DisplayAlert("Reject Discount ?", "Please press Yes to reject the discount requests or No to cancel.", "Yes", "No");

            if (responce)
            {
                IsRunningIndicator = true;
                IsListVisible      = false;

                DiscountPayload discountPayload = new DiscountPayload();
                discountPayload.ImHotelId       = Constants._hotel_number;
                discountPayload.ImReservaId     = Convert.ToInt32(TempSelectedModel.ReservationID).ToString();
                discountPayload.ImOrderId       = "1";
                discountPayload.ImScoodApprover = Settings.Username;
                discountPayload.ImStatus        = "R";
                discountPayload.ImReason        = $"Rejected by {Settings.Username}";


                var serviceRes = await POSTServicesAPI.ApproveDiscount(discountPayload);

                if (serviceRes == "Success")
                {
                    //Changing status on view
                    ChangeStatus("Rejected");

                    await Application.Current.MainPage.DisplayAlert("Rejected!", serviceRes, "OK");

                    IsRunningIndicator = false;
                    IsListVisible      = true;
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Error!", serviceRes, "OK");

                    IsRunningIndicator = false;
                    IsListVisible      = true;
                }
            }
        }