Beispiel #1
0
        public void GivenTheFollowingBookableAppointments(string length, string dueDate)
        {
            EventToBook appointment = new EventToBook();

            appointment.Length  = TimeSpan.Parse(length);
            appointment.DueDate = DateTime.Parse(dueDate);
            appointment.Type    = 2;
            AppointmentsToBook.Add(appointment);
        }
Beispiel #2
0
        public bool OnEventToBookCheck(EventToBook toBook, User user)
        {
            if (user == null)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(toBook.SkillSetRequired))
            {
                if (!user.SkillSet.Contains(toBook.SkillSetRequired))
                {
                    return(false);
                }
            }

            return(OnAdditionalEventToBookCheck(toBook, user));
        }
Beispiel #3
0
        private Event AllotAppointment(EventToBook toBook, User diaryUser, DateTime dueDate, DateTime maxDueDate)
        {
            DateTime startOfDay = diaryUser.WorkingDays[dueDate.DayOfWeek].Start;
            DateTime endOfDay   = diaryUser.WorkingDays[dueDate.DayOfWeek].Finish;
            DateTime startDate  = dueDate.AddHours(startOfDay.Hour);

            startDate = startDate.AddMinutes(startOfDay.Minute);

            DateTime endDate = startDate + toBook.Length;

            _EventStore.FindFreePeriod(diaryUser.Name, ref startDate, ref endDate, toBook.Length);


            if (startDate > maxDueDate)
            {
                return(null);
            }


            if ((endDate.Date != startDate.Date) ||
                (endDate.TimeOfDay > endOfDay.TimeOfDay))
            {
                dueDate = startDate.Date.AddDays(1);
                DateTime?newDate = FindValidWorkingDay(diaryUser, dueDate, toBook.Length);
                if (newDate != null)
                {
                    return(AllotAppointment(toBook, diaryUser, newDate.Value, maxDueDate));
                }
            }

            return(new Event(
                       Guid.NewGuid().ToString(),
                       diaryUser.Name,
                       toBook.DueDate,
                       startDate,
                       endDate,
                       toBook.Text,
                       toBook.Type));
        }
Beispiel #4
0
 public virtual bool OnAdditionalEventToBookCheck(EventToBook toBook, User user)
 {
     return(true);
 }