// GET: AppointmentBooking/Create
        public ActionResult Create()
        {
            AppointmentBookingDto appointmentBookingDto = new AppointmentBookingDto();
            string URL = "DoctorData/GetListOfDoctors";
            HttpResponseMessage httpResponse = client.GetAsync(URL).Result;

            if (httpResponse.IsSuccessStatusCode)
            {
                List <SelectListItem>   doctorSelectList = new List <SelectListItem>();
                IEnumerable <DoctorDTO> doctorList       = httpResponse.Content.ReadAsAsync <IEnumerable <DoctorDTO> >().Result;

                foreach (var d in doctorList)
                {
                    doctorSelectList.Add(new SelectListItem
                    {
                        Text  = "Dr." + d.LastName,
                        Value = d.DoctorID.ToString()
                    });
                }
                Debug.WriteLine(doctorSelectList);
                appointmentBookingDto.doctorSelectList = doctorSelectList;
                return(View(appointmentBookingDto));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        // Shows detail for a certain entry
        // GET: AppointmentBooking/Details/5
        public ActionResult Details(int id)
        {
            string url = "AppointmentBookingData/GetAppointmentBooking/" + id;
            HttpResponseMessage httpResponse = client.GetAsync(url).Result;

            if (httpResponse.IsSuccessStatusCode)
            {
                AppointmentBookingDto selectedBooking = new AppointmentBookingDto();
                selectedBooking = httpResponse.Content.ReadAsAsync <AppointmentBookingDto>().Result;

                url          = "DoctorData/GetDoctor/" + selectedBooking.DoctorID;
                httpResponse = client.GetAsync(url).Result;
                ListAppointment ViewModel = new ListAppointment
                {
                    isadmin = User.IsInRole("Admin"),
                    appointmentBookingDto = selectedBooking,
                    doctorDto             = httpResponse.Content.ReadAsAsync <DoctorDTO>().Result
                };
                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Example #3
0
        public IHttpActionResult GetAppointmentsForDoctor(int id)
        {
            List <AppointmentBooking> appointmentBookings = db
                                                            .AppointmentBookings
                                                            .Where(a => a.DoctorID == id)
                                                            .ToList();
            List <AppointmentBookingDto> appointmentBookingDtos = new List <AppointmentBookingDto> {
            };

            foreach (var appointment in appointmentBookings)
            {
                AppointmentBookingDto appointmentBookingDto = new AppointmentBookingDto
                {
                    AppointmentID      = appointment.AppointmentID,
                    AppointmentDate    = appointment.AppointmentDate,
                    FirstName          = appointment.FirstName,
                    LastName           = appointment.LastName,
                    PhoneNumber        = appointment.PhoneNumber,
                    RequestDescription = appointment.RequestDescription,
                    Confirmation       = appointment.Confirmation,
                    DoctorID           = appointment.DoctorID
                };
                appointmentBookingDtos.Add(appointmentBookingDto);
            }
            return(Ok(appointmentBookingDtos));
        }
        public ActionResult Edit(int id)
        {
            string url = "AppointmentBookingData/GetAppointmentBooking/" + id;
            HttpResponseMessage httpResponse = client.GetAsync(url).Result;

            if (httpResponse.IsSuccessStatusCode)
            {
                AppointmentBookingDto selectedBooking = new AppointmentBookingDto();
                selectedBooking = httpResponse.Content.ReadAsAsync <AppointmentBookingDto>().Result;

                url          = "DoctorData/GetListOfDoctors";
                httpResponse = client.GetAsync(url).Result;
                List <SelectListItem>   doctorSelectList = new List <SelectListItem>();
                IEnumerable <DoctorDTO> doctorList       = httpResponse.Content.ReadAsAsync <IEnumerable <DoctorDTO> >().Result;

                foreach (var d in doctorList)
                {
                    doctorSelectList.Add(new SelectListItem
                    {
                        Text  = "Dr." + d.LastName,
                        Value = d.DoctorID.ToString()
                    });
                }
                selectedBooking.doctorSelectList = doctorSelectList;

                return(View(selectedBooking));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Example #5
0
        public IHttpActionResult ListAppointmentBookings()
        {
            List <AppointmentBooking>    appointmentBookings    = db.AppointmentBookings.ToList();
            List <AppointmentBookingDto> appointmentBookingDtos = new List <AppointmentBookingDto> {
            };

            foreach (var appointmentBooking in appointmentBookings)
            {
                AppointmentBookingDto appointmentBookingDto = new AppointmentBookingDto
                {
                    AppointmentID      = appointmentBooking.AppointmentID,
                    FirstName          = appointmentBooking.FirstName,
                    LastName           = appointmentBooking.LastName,
                    PhoneNumber        = appointmentBooking.PhoneNumber,
                    DoctorID           = appointmentBooking.DoctorID,
                    RequestDescription = appointmentBooking.RequestDescription,
                    AppointmentDate    = appointmentBooking.AppointmentDate
                };
                appointmentBookingDtos.Add(appointmentBookingDto);
            }
            return(Ok(appointmentBookingDtos));
        }