private void SaveAppointmentToDataBase(IAppointment appointment, ICustomer customer, IMyServices service) { IDate date = kernel.Get <IDate>(); appointmentController.SaveToDatabaseEvent += emailConfirmation.OnSavedToDatabaseEventLog; appointmentController.SaveToDatabaseEvent += smsConfirmation.OnSavedToDatabaseEventLog; var date_id = dateController.GetDate(appointment.AppointmentDay, appointment.AppointmentTime).Date_Id; var customer_id = customerController.GetCustomer(customer).Customer_Id; var service_id = myServicesController.GetService(service).Service_Id; if (CheckObjectIsItNotNull(appointment, customer, service)) { if (string.IsNullOrEmpty(customer_id)) { customerController.SaveCustomer(customer); customer_id = customerController.GetCustomer(customer).Customer_Id; } if (string.IsNullOrEmpty(date_id)) { date.Day = appointment.AppointmentDay; date.Time = appointment.AppointmentTime; date.Length = appointment.AppointmentLength; date.Duration = appointment.AppointmentDuration; dateController.SaveDate(date); date_id = dateController.GetDate(date.Day, date.Time).Date_Id; appointmentController.SaveAppointment(date_id, customer_id, service_id); } else { MessageBox.Show("Termin zajęty!"); } } }