public async Task CheckAppointment() { try { var upcomingAppointments = await appointmentsAPI.FindUpcomingAppointmentsAsync(period : 5, pageSize : 30); if (upcomingAppointments == null || upcomingAppointments.TotalCount == 0) { return; } var sb = new StringBuilder(); sb.AppendLine("<h2>Upcoming appointments:</h2>"); sb.AppendLine("<ul>"); foreach (var appointment in upcomingAppointments.Data) { sb.Append("<li>") .Append(appointment.Title) .Append(" <strong> ") .Append(appointment.Date.LocalDateTime.ToShortDateString()) .Append(" </strong> ") .AppendLine("</li>"); } sb.AppendLine("</ul>"); await emailSender.SendEmailAsync("*****@*****.**", "Upcoming appointments", sb.ToString()); } catch (Exception exc) { throw new Exception("Failed to send email notification.", exc); } }
public async Task <PaginatedItems <Appointment> > FindUpcomingAppointmentsAsync(int period = 5, int pageSize = 10, int pageIndex = 0) => await client.FindUpcomingAppointmentsAsync(period, pageSize, pageIndex);