Esempio n. 1
0
        private void btAddAppointment_Click(object sender, EventArgs e)
        {
            Appoinment appoinment = new Appoinment();

            appoinment.Date = mcThisMonth.SelectionRange.Start.Date; //DateTime.Now;
            //new DateTime(2017, 4, 5);//mcThisMonth.SelectionRange.Start.Date;
            appoinment.Patient = _currentUser;
            appoinment.Doctor  = _doctor;

            string time = "0";

            if (rb1000.Checked == true)
            {
                time = "10:00";
            }
            if (rb1020.Checked == true)
            {
                time = "10:20";
            }
            if (rb1040.Checked == true)
            {
                time = "10:40";
            }
            if (rb1100.Checked == true)
            {
                time = "11:00";
            }
            if (rb1200.Checked == true)
            {
                time = "12:00";
            }


            using (var client = new HaServiceClient())
            {
                var        rooms   = client.GetRooms();
                List <int> roomNum = rooms.Select(room => room.RoomNumber).ToList();

                if (time != "0")
                {
                    foreach (
                        var item in
                        client.GetAppoinmentsByDate(mcThisMonth.SelectionRange.Start)
                        .Where(t => t.Time.Equals(time)))
                    {
                        foreach (var room in rooms)
                        {
                            if (room.RoomNumber == item.Room.RoomNumber)
                            {
                                roomNum.Remove(room.RoomNumber);
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
                if (roomNum.Count != 0)
                {
                    appoinment.Room = client.GetRoomByNumber(roomNum.First());
                    var room = client.GetRoomByNumber(roomNum.First());

                    appoinment.RecordNumber = 1;
                    appoinment.Time         = time;
                    //client.AddAppointment(appoinment);
                    client.AddAppointmentOnContext(_doctor.DoctorId, _currentUser.PatientId, room.RoomId, appoinment);
                    Refresh();
                }
                else
                {
                    return;
                }
            }



            //appoinment.Room
        }