public void CreateAppointment() { var controller = new AppointmentsController(); var start = new DateTime(2016, 1, 15, 13, 0, 0); var end = start.AddHours(2); var request = new CreateAppointmentRequest { Body = "Appointment Created from Unit Test", Location = "Cconference Room", Subject = "Appointment Unit Test", Start = start.ToString(), End = end.ToString(), Recipients = new List<string> { "*****@*****.**" } }; var result = controller.Create(request) as OkNegotiatedContentResult<CreateAppointmentResponse>; Assert.IsNotNull(result.Content.AppointId); Assert.IsNotNull(result.Content.Message); }
public IHttpActionResult Create(CreateAppointmentRequest request) { var service = ExchangeServer.Open(); var appointment = new Appointment(service); // Set the properties on the appointment object to create the appointment. appointment.Subject = request.Subject; appointment.Body = request.Body; appointment.Start = DateTime.Parse(request.Start); //appointment.StartTimeZone = TimeZoneInfo.Local; appointment.End = DateTime.Parse(request.End); //appointment.EndTimeZone = TimeZoneInfo.Local; appointment.Location = request.Location; //appointment.ReminderDueBy = DateTime.Now; foreach(var email in request.Recipients) { appointment.RequiredAttendees.Add(email); } // Save the appointment to your calendar. appointment.Save(SendInvitationsMode.SendOnlyToAll); // Verify that the appointment was created by using the appointment's item ID. Item item = Item.Bind(service, appointment.Id, new PropertySet(ItemSchema.Subject)); var response = new CreateAppointmentResponse { Message = "Appointment created: " + item.Subject, AppointId = appointment.Id.ToString() }; return Ok(response); }