public async Task<ActionResult> CreateEvent(CreateEventViewModel eventObject) { var model = eventObject; // Create EWS Appointment var request = new CreateAppointmentRequest { Body = "Created From Web App", End = DateTime.Parse(eventObject.Event.end).ToString(), Start = DateTime.Parse(eventObject.Event.start).ToString(), Location = "Web", Subject = eventObject.Event.title, Recipients = eventObject.Users }; var resp = await _client.CreateAppointment(request); // Send Emails var emailRequest = new SendEmailRequest { Recipients = eventObject.Users, Body = "Automated Email After Appointment Creation", FileAttachments = new List<string>(), Subject = "Automated Email After Appointment Creation" }; var sendEmailResponse = await _client.SendEmail(emailRequest); return RedirectToAction("Index"); }
public async Task<CreateAppointmentResponse> CreateAppointment(CreateAppointmentRequest request) { var response = new CreateAppointmentResponse(); 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", request); if (resp.IsSuccessStatusCode) { response = await resp.Content.ReadAsAsync<CreateAppointmentResponse>(); return response; } } return response; }
public void CreateAppointment() { var rep = new EWSIntegrationClient(); var start = new DateTime(2016, 1, 13, 13, 0, 0); var end = start.AddHours(1); var request = new CreateAppointmentRequest { Body = "Test Appointment From MVC Unit Test", Location = "MVC Unit Test", Subject = "MVC Unit Test Appointment", Start = start.ToString(), End = end.ToString() }; var result = rep.CreateAppointment(request).Result; Assert.IsNotNull(result.AppointId); }