public void SendUnconfirmedAppointmentsToEmployees (IConfiguration config, AppointmentService appointmentService, PhoneNumberService phoneNumberService) { DateTime dateDelay = DateConverter.CurrentEasternDateTime().AddDays(1); var unconfirmedAppointment = appointmentService.GetUnconfirmedAppointments(phoneNumberService); if (unconfirmedAppointment.Count() > 0) { EmailSender.SendUnconfirmedAppointmentsToEmployees(unconfirmedAppointment, config); } }
public List <BasicTimeSlotAppointmentCustomerInformation> GetBasicTimeSlotAppointmentCustomerInfo( PhoneNumberService phoneNumberService) { var basicTimeSlotAppointmentCustomerInformationList = new List <BasicTimeSlotAppointmentCustomerInformation>(); var timeSlots = Context.TimeSlots.Where(c => c.IsActive).ToList(); foreach (var timeSlot in timeSlots) { var appointment = Context.Appointments.FirstOrDefault(c => c.IsActive && c.IdTimeSlot == timeSlot.Id); if (appointment != null) { var basicTimeSlotAppointmentCustomerInformation = new BasicTimeSlotAppointmentCustomerInformation { CustomerInfo = new CustomerBasicInformation() }; basicTimeSlotAppointmentCustomerInformation.CustomerInfo.PhoneNumbers = new List <PhoneNumberAndTypesInformation>(); basicTimeSlotAppointmentCustomerInformation.IdTimeSlot = timeSlot.Id; basicTimeSlotAppointmentCustomerInformation.IdAppointment = appointment.Id; basicTimeSlotAppointmentCustomerInformation.NotesTimeSlot = timeSlot.Notes; var customer = Context.Customers.First(c => c.Id == appointment.IdCustomer); basicTimeSlotAppointmentCustomerInformation.CustomerInfo.Id = customer.Id; var user = Context.Users.FirstOrDefault(c => c.IdCustomer == customer.Id); if (user != null) { basicTimeSlotAppointmentCustomerInformation.CustomerInfo.Email = user.Email; } basicTimeSlotAppointmentCustomerInformation.CustomerInfo.FullName = $"{customer.FirstName} {customer.LastName}"; basicTimeSlotAppointmentCustomerInformation.CustomerInfo.PhoneNumbers = phoneNumberService.GetPhoneNumbersForCustomer(customer.Id); basicTimeSlotAppointmentCustomerInformationList.Add(basicTimeSlotAppointmentCustomerInformation); } } return(basicTimeSlotAppointmentCustomerInformationList); }
public AppointmentCustomerInformation GetAppointmentCustomerInformation(PhoneNumberService phoneNumberService, Appointment appointment) { var appointmentCustomer = new AppointmentCustomerInformation { Appointment = new Appointment(), Customer = new CustomerBasicInformation { PhoneNumbers = new List <PhoneNumberAndTypesInformation>() } }; Customer customer = Context.Customers.First(c => c.Id == appointment.IdCustomer); String customerEmail = Context.Users.FirstOrDefault(c => c.IdCustomer == customer.Id).Email; appointmentCustomer.Appointment = appointment; appointmentCustomer.Customer.Id = customer.Id; appointmentCustomer.Customer.Email = customerEmail ?? ""; appointmentCustomer.Customer.FullName = $"{customer.FirstName} {customer.LastName}"; appointmentCustomer.Customer.PhoneNumbers = phoneNumberService.GetPhoneNumbersForCustomer(customer.Id); return(appointmentCustomer); }
public ActionResult <IEnumerable <CustomerAppointmentInformation> > GetAppointmentsAndCustomers (PhoneNumberService phoneNumberService) { var appointments = ( from appointment in Context.Appointments join customer in Context.Customers on appointment.IdCustomer equals customer.Id join timeSlot in Context.TimeSlots on appointment.IdTimeSlot equals timeSlot.Id where customer.IsActive && appointment.IsActive select new CustomerAppointmentInformation() { Customer = customer, TimeSlot = timeSlot, Appointment = appointment }).AsNoTracking().ToList(); foreach (var appointment in appointments) { appointment.PhoneNumbers = phoneNumberService .GetPhoneNumbersForCustomer(appointment.Customer.Id); } return(appointments.OrderBy(c => c.TimeSlot.StartDateTime).ToList()); }
internal List <CustomerAppointmentInformation> GetUnconfirmedAppointments(PhoneNumberService phoneNumberService) { var appointments = ( from appointment in Context.Appointments join customer in Context.Customers on appointment.IdCustomer equals customer.Id join timeSlot in Context.TimeSlots on appointment.IdTimeSlot equals timeSlot.Id where customer.IsActive && appointment.IsActive && !appointment.IsConfirmed && timeSlot.StartDateTime.Date == DateConverter.CurrentEasternDateTime().Date.AddDays(1) select new CustomerAppointmentInformation() { Customer = customer, TimeSlot = timeSlot, Appointment = appointment }).AsNoTracking().ToList(); foreach (var appointment in appointments) { appointment.PhoneNumbers = phoneNumberService .GetPhoneNumbersForCustomer(appointment.Customer.Id); } return(appointments.OrderBy(c => c.TimeSlot.StartDateTime).ToList()); }
public bool SendNewAppointments(IConfiguration configuration, AppointmentService appointmentService, PhoneNumberService phoneService) { var appointments = appointmentService.GetNewAppointments(phoneService); return(EmailSender.SendNewAppointmentsToEmployees(appointments, configuration)); }