Beispiel #1
0
        public async Task <IEnumerable <GetAppoimnetsDto> > GetDoctorAppoinments(int doctorId, DoctorAppoinmentsFilterDto filterObj)
        {
            var query = _context.Appoinments
                        .Include(c => c.Pacient)
                        .Where(c => c.DoctorId == doctorId)
                        .AsQueryable();

            if (filterObj.DateFrom != 0)
            {
                query = query.Where(c => c.DateId >= filterObj.DateFrom);
            }
            if (filterObj.DateTo != 0)
            {
                query = query.Where(c => c.DateId <= filterObj.DateTo);
            }
            if (!string.IsNullOrEmpty(filterObj.PacientFirstName))
            {
                query = query.Where(c => c.Pacient.FirstName.Contains(filterObj.PacientFirstName));
            }
            if (!string.IsNullOrEmpty(filterObj.PacientSecondName))
            {
                query = query.Where(c => c.Pacient.SecondName.Contains(filterObj.PacientSecondName));
            }
            if (filterObj.StatusId != 0)
            {
                query = query.Where(c => c.StatusId == filterObj.StatusId);
            }

            return(await query
                   .ProjectTo <GetAppoimnetsDto>(_mapper.ConfigurationProvider)
                   .OrderByDescending(c => c.DateId)
                   .ToListAsync());
        }
        public async Task <ActionResult <IEnumerable <GetAppoimnetsDto> > > GetDoctorAppoinments(DoctorAppoinmentsFilterDto filterDto)
        {
            var doctorId = await _doctorRepository.GetDoctorId(User.GetUserId());

            var result = await _appoinmentsRepository.GetDoctorAppoinments(doctorId, filterDto);

            return(Ok(result));
        }