private Appointment ConvertDtoToModel(AppointmentInformation appointment) { return(new Appointment() { IdTimeSlot = appointment.IdTimeSlot, IdCustomer = appointment.IdCustomer }); }
public ActionResult AddAppointment([FromBody] AppointmentInformation appointment) { if (appointment == null) { return(BadRequest()); } var newAppointment = Service.CheckAppointmentIsAvailable(appointment); if (newAppointment == null) { return(Conflict()); } newAppointment.IsNew = true; newAppointment.IsActive = true; var appointmentAdded = Service.AddOrUpdate(newAppointment); var user = Service.GetUser(appointmentAdded); var appointmentDate = Service.GetAppointmentTimeSlot(newAppointment).StartDateTime; if (user != null) { EmailSender.SendConfirmationEmail(user.Email, appointmentDate, configuration); } return(Ok(appointmentAdded)); }
public Appointment CheckAppointmentIsAvailable(AppointmentInformation appointment) { return(Context.TimeSlots.Any(c => c.Id == appointment.IdTimeSlot) ? Context.Appointments.Any(c => c.IdTimeSlot == appointment.IdTimeSlot) ? null : ConvertDtoToModel(appointment) : null); }