예제 #1
0
        private void ValidateAppointmentInterval(DateTime initialDate, DateTime finalDate, int?id = null)
        {
            if (initialDate >= finalDate)
            {
                throw new DomainException("Appointment start must be before finish");
            }

            var appointments = _repository
                               .AppointmentsBetween(initialDate, finalDate);

            if (id.HasValue)
            {
                appointments = appointments.Where(a => a.Id != id);
            }

            if (appointments.Count() > 0)
            {
                throw new DomainException("Exists another appointment at selected interval");
            }
        }