public string UpdateAppointment(UpdateBookAppointment appointment)
        {
            try
            {
                DateTime obj = DateTime.Parse(appointment.Start);
                appointment.Start = obj.ToString("yyyy-MM-dd T HH:mm:ss");
                appointment.End   = obj.AddMinutes(appointment.EndMinute).ToString("yyyy-MM-dd T HH:mm:ss");

                var StartTime = DateTime.Parse(appointment.StartHour, CultureInfo.InvariantCulture);
                var Time      = StartTime.ToString("HH:mm").Split(':');

                appointment.StartHour   = Time[0];
                appointment.StartMinute = Time[1];

                string apiURL         = ConfigurationManager.AppSettings["DomainUrl"].ToString() + "/api/booking/UpdateBooking";
                string result         = "";
                var    httpWebRequest = (HttpWebRequest)WebRequest.Create(apiURL);
                httpWebRequest.ContentType     = "application/json";
                httpWebRequest.Method          = "POST";
                httpWebRequest.ProtocolVersion = HttpVersion.Version10;
                httpWebRequest.Headers.Add("Token", Request.Headers["Token"]);

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    var jsonString = new JavaScriptSerializer().Serialize(appointment);
                    streamWriter.Write(jsonString);
                    streamWriter.Flush();
                    streamWriter.Close();
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    result = streamReader.ReadToEnd();
                }

                return(result);
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
        public void UpdateAppointments()
        {
            try
            {
                //string[] AppointmentDate = { };
                //string[] TimeAppointment = { };
                //string[] hours = { };
                //string[] Endmins = { };
                //string[] Endmin = { };
                //string Time = UpdateAppointmentTime.Text;
                //if (Time != null)
                //{
                //    TimeAppointment = Time.Split('-');
                //    hours = TimeAppointment[0].Split(':');
                //    Endmins = TimeAppointment[1].Split(':');
                //    Endmin = Endmins[1].Split(' ');
                //}
                //if (AppointmentsPicker.SelectedItem != null)
                //{
                //    string selectedValue = (AppointmentsPicker.SelectedItem).ToString();
                //    Data.TryGetValue(selectedValue, out StatusId);
                //}
                //var GetAllCustomerData = GetAllCustomer();
                //List<int> custIDs = GetAllCustomerData.Select(z => z.Id).ToList();
                //UpdatebookAppointment = new UpdateBookAppointment();
                //UpdatebookAppointment.Id = Application.Current.Properties["BookingID"].ToString();
                //UpdatebookAppointment.CompanyId = Convert.ToInt32(Application.Current.Properties["CompanyId"]);
                //UpdatebookAppointment.EmployeeId = EmpID;
                //UpdatebookAppointment.ServiceId = ServiceID;
                //UpdatebookAppointment.CustomerIdsCommaSeperated = CustID.ToString();
                //UpdatebookAppointment.StartHour = Convert.ToInt32(hours[0]);
                //UpdatebookAppointment.StartMinute = 0;
                //UpdatebookAppointment.EndHour = 0;
                //UpdatebookAppointment.EndMinute = Convert.ToInt32(Endmin[0]);
                //UpdatebookAppointment.IsAdded = true;
                //UpdatebookAppointment.Message = UpdateComment.Text;
                //UpdatebookAppointment.Notes = UpdateComment.Text;
                //UpdatebookAppointment.CustomerIds = custIDs;
                //UpdatebookAppointment.Start = dateOfBooking;
                //UpdatebookAppointment.End = dateOfBooking;
                //UpdatebookAppointment.Status = StatusId;

                UpdatebookAppointment            = new UpdateBookAppointment();
                UpdatebookAppointment.Id         = BookingID;
                UpdatebookAppointment.CompanyId  = CompanyId;
                UpdatebookAppointment.ServiceId  = ServiceID;
                UpdatebookAppointment.EmployeeId = EmpID;
                UpdatebookAppointment.CustomerIdsCommaSeperated = CustID.ToString();
                UpdatebookAppointment.StartHour   = StartHour;
                UpdatebookAppointment.StartMinute = StartMinutes;
                UpdatebookAppointment.EndHour     = EndHour;
                UpdatebookAppointment.EndMinute   = EndMinute;
                UpdatebookAppointment.IsAdded     = true;
                UpdatebookAppointment.Message     = "";

                var        GetAllCustomerData = GetAllCustomer();
                List <int> custIDs            = GetAllCustomerData.Select(x => x.Id).ToList();
                custIDs = custIDs.Where(x => x == CustID).ToList();
                UpdatebookAppointment.CustomerIds = custIDs;
                var sDate = dateOfBooking.ToString("yyyy-MM-dd T HH:mm:ss");
                UpdatebookAppointment.Start = sDate;
                var eeDate = dateOfBooking.ToString("yyyy-MM-dd T HH:mm:ss");
                UpdatebookAppointment.End = eeDate;
                if (AppointmentsPicker.SelectedItem != null)
                {
                    string selectedValue = (AppointmentsPicker.SelectedItem).ToString();
                    Data.TryGetValue(selectedValue, out StatusId);
                }
                UpdatebookAppointment.Status = StatusId;
                UpdatebookAppointment.Notes  = "";



                var             SerializedData      = JsonConvert.SerializeObject(UpdatebookAppointment);
                var             apiUrl              = Application.Current.Properties["DomainUrl"] + "api/booking/UpdateBooking";
                var             result              = PostData("POST", SerializedData, apiUrl);
                BookAppointment objBookappointments = new BookAppointment();
                objBookappointments.CompanyId = UpdatebookAppointment.CompanyId;
                objBookappointments.CustomerIdsCommaSeperated = UpdatebookAppointment.CustomerIdsCommaSeperated;
                objBookappointments.EmployeeId  = UpdatebookAppointment.EmployeeId;
                objBookappointments.ServiceId   = UpdatebookAppointment.ServiceId;
                objBookappointments.StartHour   = UpdatebookAppointment.StartHour;
                objBookappointments.StartMinute = UpdatebookAppointment.StartMinute;
                objBookappointments.EndHour     = UpdatebookAppointment.EndHour;
                objBookappointments.EndMinute   = UpdatebookAppointment.EndMinute;
                objBookappointments.IsAdded     = UpdatebookAppointment.IsAdded;
                objBookappointments.Message     = UpdatebookAppointment.Message;
                objBookappointments.Notes       = UpdatebookAppointment.Notes;
                objBookappointments.CustomerIds = UpdatebookAppointment.CustomerIds;
                objBookappointments.Start       = UpdatebookAppointment.Start.ToString();
                objBookappointments.End         = UpdatebookAppointment.End.ToString();
                objBookappointments.Status      = UpdatebookAppointment.Status;

                dynamic data = JObject.Parse(result);
                var     msg  = Convert.ToString(data.Message);
                DisplayAlert("Success", msg, "ok");

                for (int PageIndex = Navigation.NavigationStack.Count - 1; PageIndex >= 4; PageIndex--)
                {
                    Navigation.RemovePage(Navigation.NavigationStack[PageIndex]);
                }

                // Navigation.PopAsync(true);

                Navigation.PushAsync(new AddAppointmentsPage(objBookappointments));
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }