Пример #1
0
        public bool CheckFreeTerm(DateTime?start, FunctionType type)
        {
            if (start != null)
            {
                FunctionItem funItem = getFuntionItem(type);
                DateTime     end;
                if (funItem != null)
                {
                    end = new DateTime(funItem.Time.Ticks + start.Value.Ticks);
                    IFunction   item = null;
                    CalendarDay day  = Calendar.Where(x => x.Date.Date.CompareTo(start.Value.Date) == 0).FirstOrDefault();

                    if (day != null)
                    {
                        item = day.CalendarItems.Where(x =>
                                                       (x.DateTimeStart >= start && x.DateTimeStart > end) &&
                                                       (x.DateTimeEnd <= start && x.DateTimeEnd <= end) ||
                                                       (x.DateTimeStart <= start && x.DateTimeEnd <= end)
                                                       ).FirstOrDefault();

                        if (item == null)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Пример #2
0
        public IFunction addCalendarItem(Person patient, FunctionType functionType, DateTime?TimeStart)
        {
            if (TimeStart.HasValue && patient != null)
            {
                FunctionItem funItem = getFuntionItem(functionType);
                DateTime     timeEnd = new DateTime(funItem.Time.Ticks + TimeStart.Value.Ticks);

                CalendarDay day = Calendar.Where(x => x.Date.Date.CompareTo(TimeStart.Value.Date) == 0).FirstOrDefault();
                if (day != null)
                {
                    IFunction exam = ExamExtension.getExam(functionType);
                    exam.patient       = patient;
                    exam.NamePerformer = $"{Name} {LastName}";
                    exam.DateTimeStart = TimeStart.Value;
                    exam.DateTimeEnd   = timeEnd;

                    day.CalendarItems.Add(exam);

                    return(exam);
                }
            }

            return(null);
        }