コード例 #1
0
        private IAppointmentDetails BuildAppointmentDetails(string[] idColumnSet)
        {
            IAppointmentDetails appointmentDetails = kernel.Get <IAppointmentDetails>();
            IDate       date     = kernel.Get <IDate>();
            ICustomer   customer = kernel.Get <ICustomer>();
            IMyServices service  = kernel.Get <IMyServices>();

            if (idColumnSet.Length > 0)
            {
                customer = customerController.GetCustomer(idColumnSet[1]);
                service  = myServicesController.GetService(idColumnSet[2]);
                date     = dateController.GetDate(idColumnSet[3]);

                appointmentDetails.Forename            = customer.Forename;
                appointmentDetails.Surname             = customer.Surname;
                appointmentDetails.Telephone           = customer.Telephone;
                appointmentDetails.AppointmentDay      = date.Day;
                appointmentDetails.AppointmentTime     = date.Time;
                appointmentDetails.AppointmentDuration = date.Duration;
                appointmentDetails.AppointmentLength   = date.Length;
                appointmentDetails.AppointmentId       = idColumnSet[0];
                appointmentDetails.Name = service.Name;
            }
            return(appointmentDetails);
        }
コード例 #2
0
        public void BuildAppointment(IAppointment appointment, ICustomer customer, IMyServices service)
        {
            bool   IsTimeAvailable = false;
            string timeToCalculate = null;

            double.TryParse(appointment.AppointmentDuration, out double multiplier);
            DateTime.TryParse(appointment.AppointmentTime, out DateTime appointmentTime);

            int newTimeAppointmentInMinutes = (int)(60 * (multiplier / 2));

            // minuta po minucie sprawdzaj zajętość pola
            for (int i = 0; i < newTimeAppointmentInMinutes; i++)
            {
                timeToCalculate = appointmentTime.AddMinutes(i).ToShortTimeString();
                // kolizja z następnym terminem
                if (dateController.GetDate(appointment.AppointmentDay, timeToCalculate).Date_Id == null)
                {
                    IsTimeAvailable = true;
                }
                else
                {
                    IsTimeAvailable = false;
                    break;
                }
            }

            IsTimeAvailable = CheckAvailableTimeToEndOfWorkInMinutes(appointment, IsTimeAvailable, newTimeAppointmentInMinutes);

            if (IsTimeAvailable)
            {
                try
                {
                    SaveAppointmentToDataBase(appointment, customer, service);
                }
                catch (Exception)
                {
                    MessageBox.Show("AppointmentProcessor Error");
                }
            }
            else
            {
                MessageBox.Show("Termin jest zajęty! Wybierz inny termin wizyty!");
            }
        }