Exemplo n.º 1
0
        public void TestAppointment()
        {
            var appointmentDetailId = 10;
            var appointmentDetail   = CalendarServicePoint.GetAppointmentDetailById(appointmentDetailId);

            Assert.IsNotNull(appointmentDetail.Appointment);
            Assert.AreEqual(appointmentDetail.Id, appointmentDetailId);
        }
        public void ProcessRequest(HttpContext context)
        {
            CalendarServicePoint.DataLoad();

            context.Response.ContentType = "application/json";
            var req = context.Request.RawUrl.Split(new char[] { '/' });

            if (req.Length > 2)
            {
                switch (req[2])
                {
                case Paths.Appointments:
                {
                    if (CalendarServiceRequestValidation.AppointmentsRequestIsValid(req))
                    {
                        var appointments = CalendarServicePoint.GetAllAppointmentsByMonth(Convert.ToInt32(req[3]));
                        context.Response.Write(JsonConvert.SerializeObject(appointments));
                    }
                    else
                    {
                        WriteErrorToRequest(context);
                    }
                    break;
                }

                case Paths.AppointmentDetail:
                {
                    if (CalendarServiceRequestValidation.AppointmentDetailRequestIsValid(req))
                    {
                        var appointment = CalendarServicePoint.GetAppointmentDetailById(Convert.ToInt32(req[3]));
                        context.Response.Write(JsonConvert.SerializeObject(appointment));
                    }
                    else
                    {
                        WriteErrorToRequest(context);
                    }
                    break;
                }

                default:
                {
                    WriteErrorToRequest(context);
                    break;
                }
                }
            }
        }