예제 #1
0
        public async Task <SetTimeSlotResponseModel> SetCalenderEvent(SetTimeSlotsRequestModel setTimeSlots)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    var uri     = new Uri("http://104.238.81.169:4080/FitnessApp/manageservices/v1/members/addTimeSlots");
                    var json    = JsonConvert.SerializeObject(setTimeSlots);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");

                    HttpResponseMessage response = null;

                    response = await client.PostAsync(uri, content);

                    if (response.IsSuccessStatusCode)
                    {
                        var responseJson = response.Content.ReadAsStringAsync().Result;
                        var result       = JsonConvert.DeserializeObject <SetTimeSlotResponseModel>(responseJson);
                        return(result);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
            return(null);
        }
예제 #2
0
        public async Task <string> SetCalenderEvent(SetTimeSlotsRequestModel setTimeSlots)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                var uri = new Uri("https://trainmeapp.in:8443/FitnessApp/manageservices/v1/members/addTimeSlots");

                try
                {
                    var json    = JsonConvert.SerializeObject(setTimeSlots);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");

                    HttpResponseMessage response = null;

                    response = await client.PostAsync(uri, content);

                    if (response.IsSuccessStatusCode)
                    {
                        var responseJson = response.Content.ReadAsStringAsync().Result;
                        SetTimeSlotResponseModel responseItem = JsonConvert.DeserializeObject <SetTimeSlotResponseModel>(responseJson);

                        if (responseItem.status.status == "SUCCESS")
                        {
                            return("Success");
                        }
                        else
                        {
                            return("Internal Server Error. Please try again.");
                        }
                    }
                    else
                    {
                        return("Internal Server Error. Please try again.");
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(@"ERROR {0}", ex.Message);
                    return("Internal Server Error. Please try again.");
                }
            }
            else
            {
                return("Internet Connectivity error. Please try again.");
            }
        }
예제 #3
0
 Task <SetTimeSlotResponseModel> IRestService.SetCalenderEvent(SetTimeSlotsRequestModel setTimeSlots)
 {
     throw new NotImplementedException();
 }
예제 #4
0
 public Task <string> SetCalenderEvent(SetTimeSlotsRequestModel setTimeSlots)
 {
     throw new NotImplementedException();
 }
예제 #5
0
        //void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
        //{
        //    // don't do anything if we just de-selected the row.
        //    if (e.SelectedItem == null) return;

        //    // Deselect the item.
        //    if (sender is ListView lv) lv.SelectedItem = null;

        //}

        async void Handle_Calender(object sender, System.EventArgs e)
        {
            int count = 0;

            for (int index = 0; index < calenderViewModel.Attendances.Count; index++)
            {
                if (calenderViewModel.Attendances[index].BackgroundColor == Color.Green)
                {
                    count = count + 1;
                }
            }

            if (count == 0)
            {
                await DisplayAlert("Alert", "Please select minimum 1 day.", "Ok");
            }
            else
            {
                var result = await DisplayAlert("Alert", "Are you sure, you want to pay for " + count + " days?", "Accept", "Cancel");

                if (result)
                {
                    SetTimeSlotsRequestModel setTimeSlots = new SetTimeSlotsRequestModel();
                    setTimeSlots.emailID      = App.TrainerData.Email;
                    setTimeSlots.addByEmailID = App.LoginResponse.Email;

                    List <Models.SetTimeSlotsRequestModel.TimeSlot> timeSlots = new List <Models.SetTimeSlotsRequestModel.TimeSlot>();

                    foreach (var item in calenderViewModel.Attendances)
                    {
                        if (item.BackgroundColor == Color.Green)
                        {
                            Models.SetTimeSlotsRequestModel.TimeSlot timeSlot = new Models.SetTimeSlotsRequestModel.TimeSlot();
                            timeSlot.day   = item.Date.Day.ToString();
                            timeSlot.month = item.Date.Month.ToString();
                            timeSlot.year  = item.Date.Year.ToString();

                            int index = calenderViewModel.Attendances.IndexOf(item);

                            timeSlot.startTime          = calenderViewModel.Schedules[index].StartTime;
                            timeSlot.endTime            = calenderViewModel.Schedules[index].EndTime;
                            timeSlot.serviceReferneceId = calenderViewModel.Schedules[index].ServiceRefId;
                            timeSlot.serviceId          = calenderViewModel.ServiceId;
                            timeSlot.remarks            = "Appointment";

                            timeSlots.Add(timeSlot);
                        }
                    }



                    setTimeSlots.timeSlot = timeSlots;

                    var slotResponseModel = await App.TodoManager.SetTimeSlot(setTimeSlots);

                    if (slotResponseModel != null && !string.IsNullOrEmpty(slotResponseModel.status.status) && slotResponseModel.status.status.ToLower().Equals("success"))
                    {
                        var paymentRequest = new PaymentRequest
                        {
                            BusinessTransaction = new BusinessTransaction
                            {
                                PayeeId = App.TrainerData.Email,
                                PayerId = App.LoginResponse.Email,
                                Amount  = (count * Convert.ToDouble(calenderViewModel.Charges)) + "",
                                EventId = slotResponseModel.status.slotId
                            }
                        };
                        var paymentResponse = await App.TodoManager.StartPayment(paymentRequest);

                        if (paymentResponse != null && paymentResponse.TransactionStatus != null && !string.IsNullOrEmpty(paymentResponse.TransactionStatus.processURL))
                        {
                            await this.Navigation.PushAsync(new PaymentPage(paymentResponse.TransactionStatus.processURL));
                        }
                    }
                }
            }
        }