public static int AddAppointment(Appointment newAppointment, Band b)
        {
            AddBandWrapper abWrapper = new AddBandWrapper(b, newAppointment);
            WebResponse resp = POST(Uri + "/rest/bands/appointments", JsonConvert.SerializeObject(abWrapper));

            String id = new StreamReader(resp.GetResponseStream()).ReadToEnd();
            return int.Parse(JsonConvert.DeserializeObject<String>(id));
        }
        private void btnAcceptAppearanceRequest_Click(object sender, RoutedEventArgs e)
        {
            //remove from app requests and add to appointments and appearance
            AppearanceRequest requestToUpdate = (AppearanceRequest)this.dgReceivedAppearanceRequests.SelectedItem;

            //remove from appRequests
            WebserviceManager.RemoveAppearanceRequest(requestToUpdate.Id);

            this.currentBand.AppearanceRequests.Remove(requestToUpdate);
            this.dgReceivedAppearanceRequests.Items.Refresh();

            //add to appointments
            Appointment newAppointment = new Appointment(requestToUpdate);

            //TODO-----------------------
            newAppointment.Id = WebserviceManager.AddAppointment(newAppointment, currentBand);

            WebserviceManager.AddAppearance(currentBand, newAppointment);
            this.currentBand.Appointments.Add(newAppointment);

            this.dgAppointments.Items.Refresh();
        }
        //TODO
        private void btnAcceptRehearsalRequest_Click(object sender, RoutedEventArgs e)
        {
            RehearsalRequest rehReq = (RehearsalRequest)this.dgRehearsalRequests.SelectedItem;
            String name = this.tbNameFixRehearsal.Text;
            String description = this.tbDescriptionFixRehearsal.Text;
            AvailableTime mustBeBetweenTime = (AvailableTime)this.lvSuggestedTimesRehearsalRequest.SelectedItem;
            rehReq.StartTime = this.dtpFixRehearsalStart.Value.Value;
            rehReq.EndTime = rehReq.StartTime.AddHours(rehReq.Duration);
            Model.Location location = (Model.Location)this.cbLocationsFixRehearsal.SelectedItem;
            Appointment newAppointment = new Appointment(name, description, location, rehReq);
            newAppointment.Grounded = 1;
            //TODO: generate appointment_attendances!

            if (mustBeBetweenTime != null && newAppointment.StartTime >= mustBeBetweenTime.StartTime && newAppointment.EndTime <= mustBeBetweenTime.EndTime)
            {
                newAppointment.Id = WebserviceManager.AddAppointment(newAppointment, currentBand);
                WebserviceManager.AddAppearance(currentBand, newAppointment);

                this.currentBand.Appointments.Add(newAppointment);
                this.dgAppointments.ItemsSource = currentBand.Appointments;
                this.Window_Loaded(this, null);
                this.dgRehearsalRequests.Items.Refresh();
            }
            else
            {
                this.printError("Mögliche Zeit muss selektiert werden und eingetragene Startzeit(+ Probedauer) muss in diesem Intervall liegen!");
            }
        }
        private void btnCreateAppointment_Click(object sender, RoutedEventArgs e)
        {
            String name = this.tbNameNewAppointment.Text;
            String description = this.tbDescriptionNewAppointment.Text;
            DateTime? startTime = this.dtpNewAppointmentStart.Value;
            DateTime? endTime = this.dtpNewAppointmentEnd.Value;
            Model.Location location = (Model.Location)this.cbLocations.SelectedItem;
            Appointment newAppointment = new Appointment(name, description, startTime, endTime, location, EnumAppointmentType.Appearance);

            newAppointment.Id = WebserviceManager.AddAppointment(newAppointment, currentBand);
            WebserviceManager.AddAppearance(currentBand, newAppointment);

            this.currentBand.Appointments.Add(newAppointment);
            this.dgAppointments.Items.Refresh();
        }
 public static void RemoveAppointment(Appointment app)
 {
     DELETE(Uri + "/rest/appointments", JsonConvert.SerializeObject(app));
 }
        public static bool AllMembersOfBandAccepted(Band currentBand, Appointment appointmentToUpdate)
        {
            String data = GET(Uri + "/rest/appointments/"+ currentBand.Name + "/" + appointmentToUpdate.Id);

            return Boolean.Parse(JsonConvert.DeserializeObject<String>(data));
        }