public void GetAvailability() { var rep = new EWSIntegrationClient(); var request = new AvailabilityRequest { DurationMinutes = 60, Start = DateTime.UtcNow.ToString(), End = DateTime.UtcNow.AddDays(30).ToString(), Users = new List<string> { "*****@*****.**" } }; var result = rep.GetAvailability(request).Result; Assert.IsNotNull(result.AvailabilityResult); }
public async Task<AvailabilityResponse> GetAvailability(AvailabilityRequest request) { var response = new AvailabilityResponse(); 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/availability", request); if (resp.IsSuccessStatusCode) { response = await resp.Content.ReadAsAsync<AvailabilityResponse>(); return response; } } return response; }
private async Task<AppointmentManager> CreateModel(List<string> users, string start, string end) { var request = new AvailabilityRequest { DurationMinutes = 60, Start = DateTime.Parse(start).ToString(), End = DateTime.Parse(end).ToString(), Users = users == null ? new List<string>() : users }; var result = await _client.GetAvailability(request); var obj = result.AvailabilityResult; int i = 0; // Part of a hack. for this demo we only expect <=5 users. var colorIndex = 0; var list = new List<EventObject>(); foreach (var avai in result.AvailabilityResult) { var color = _colors[(i == _colors.Count) ? colorIndex = 0 : colorIndex++]; foreach (var block in avai.Availability) { var eventObject = new EventObject { title = "Interviewer " + i + " Status: " + block.Status, start = block.Start.ToString("o"), end = block.End.ToString("o"), allDay = false, backgroundColor = color }; list.Add(eventObject); } i++; } var model = new AppointmentManager { Events = list }; return model; }