Esempio n. 1
0
        public async Task <IEnumerable <AppointmentDto> > GetAsync(DateTime?date, DateRange range)
        {
            date ??= DateTime.Today;

            DateTime rangeStartTime = DateHelper.GetStartTime(date.Value, range);
            DateTime rangeEndTime   = DateHelper.GetEndTime(date.Value, range);

            IQueryable <Appointment> entities = await _mediator.Send(new List.Query <Appointment>(
                                                                         predicate: a =>
                                                                         a.EndTime <= rangeEndTime && a.EndTime >= rangeStartTime ||
                                                                         a.EndTime > rangeEndTime && a.StartTime <= rangeEndTime,
                                                                         asSplitQuery: true));

            var dtoList   = new List <AppointmentDto>();
            var treeQuery = new Domain.Logic.Sections.FlattenedTree.Query();
            IEnumerable <ITree <Section> > flattenedTree = await _mediator.Send(treeQuery);

            foreach (Appointment appointment in entities)
            {
                AppointmentDto dto = _mapper.Map <AppointmentDto>(appointment);
                await AddParticipationsAsync(dto, appointment, flattenedTree);

                dtoList.Add(dto);
            }
            return(dtoList);
        }
Esempio n. 2
0
        public async Task <MyAppointmentListDto> GetMyAppointmentsAsync(int?limit, int?offset)
        {
            var treeQuery = new Domain.Logic.Sections.FlattenedTree.Query();
            IEnumerable <ITree <Section> > flattenedTree = await _mediator.Send(treeQuery);

            Person currentPerson = await _userAccessor.GetCurrentPersonAsync();

            Tuple <IQueryable <Appointment>, int> appointmentTuple = await _mediator.Send(
                new AppointmentList.Query(limit, offset, flattenedTree, currentPerson));

            IList <MyAppointmentDto> myAppointmentDtos = await appointmentTuple.Item1
                                                         .ProjectTo <MyAppointmentDto>(_mapper.ConfigurationProvider)
                                                         .ToListAsync();

            foreach (MyAppointmentDto dto in myAppointmentDtos)
            {
                AppointmentParticipation participation = await _mediator.Send(new Domain.Logic.AppointmentParticipations.Details.Query(
                                                                                  dto.Id, currentPerson.Id));

                if (participation != null)
                {
                    _mapper.Map(participation, dto);
                }
            }

            return(new MyAppointmentListDto
            {
                TotalRecordsCount = appointmentTuple.Item2,
                UserAppointments = myAppointmentDtos
            });
        }
Esempio n. 3
0
        public override async Task <AppointmentDto> GetByIdAsync(Guid id)
        {
            Appointment appointment = await _mediator.Send(new Details.Query <Appointment>(id));

            AppointmentDto dto       = _mapper.Map <AppointmentDto>(appointment);
            var            treeQuery = new Domain.Logic.Sections.FlattenedTree.Query();
            IEnumerable <ITree <Section> > flattenedTree = await _mediator.Send(treeQuery);

            await AddParticipationsAsync(dto, appointment, flattenedTree);

            return(dto);
        }
Esempio n. 4
0
        public async Task <AppointmentDto> SetDatesAsync(AppointmentSetDatesDto setDatesDto)
        {
            SetDates.Command command     = _mapper.Map <SetDates.Command>(setDatesDto);
            Appointment      appointment = await _mediator.Send(command);

            AppointmentDto dto       = _mapper.Map <AppointmentDto>(appointment);
            var            treeQuery = new Domain.Logic.Sections.FlattenedTree.Query();
            IEnumerable <ITree <Section> > flattenedTree = await _mediator.Send(treeQuery);

            await AddParticipationsAsync(dto, appointment, flattenedTree);

            return(dto);
        }