コード例 #1
0
        public async Task<GetAppointmentsResponse> GetAppointments(GetAppointmentsRequest request)
        {
            var response = new GetAppointmentsResponse();

            using (var client = new HttpClient())
            {

                client.BaseAddress = new Uri(_url);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage resp = await client.PostAsJsonAsync("/api/appointments/details", request);
                if (resp.IsSuccessStatusCode)
                {
                    response = await resp.Content.ReadAsAsync<GetAppointmentsResponse>();

                    return response;
                }
            }
            return response;
        }
コード例 #2
0
        private async Task<InterviewScheduleViewModel> CreateModel(string start, string end)
        {


            var request = new GetAppointmentsRequest
            {
                Start = start,
                End = end
            };

            var response = await _client.GetAppointments(request);

            var events = new List<EventObject>();
            int i = 0;
            foreach (var app in response.Appointments)
            {
                events.Add(new EventObject
                {
                    title = app.Subject,
                    start = app.Start.ToString("o"),
                    end = app.End.ToString("o"),
                    allDay = false,
                    backgroundColor = "green"
                });

                response.Appointments.ElementAt(i).StartViewTime = response.Appointments.ElementAt(i).Start.ToString("t");
                response.Appointments.ElementAt(i).EndViewTime = response.Appointments.ElementAt(i).End.ToString("t");
                i++;
            }
            var model = new InterviewScheduleViewModel
            {
                Appointments = response.Appointments,
                Events = events,
                Start = start,
                End = end
            };

            return model;
        }