public async Task <IActionResult> DoctorsListPaging([FromBody] DoctorFilterDTO filterModel, int pageIndex, int limit) { var(totalCount, _, doctors) = await _doctorsService.GetDoctorsListPagingAsync(filterModel, RequestLang, HostAddress, pageIndex); var result = new DoctorsResultDTO { TotalCount = totalCount, Doctors = doctors }; return(Ok(result)); }
public async Task <DoctorsResultDTO> GetFavoriateDoctorsAsync(FavoriatesDTO model, Lang lang, string hostAddress) { if (model == null || !model.Favorites.Any()) { return new DoctorsResultDTO { TotalCount = 0, Doctors = new List <DoctorListItemDTO>() } } ; var query = _serviceSupplyService.Table; query = query.Where(x => x.ShiftCenter.SupportAppointments); query = query.Where(x => model.Favorites.Any(f => f.ServiceSupplyId == x.Id) && /*x.IsAvailable*/ x.Id != 1 && x.Id != 65); var totalCount = await query.LongCountAsync(); var doctors = (from x in query.AsEnumerable() let shiftCenterService = x.ShiftCenter.PolyclinicHealthServices.FirstOrDefault(ss => ss.Id == model.Favorites.FirstOrDefault(f => f.ServiceSupplyId == x.Id)?.CenterServiceId) let firstExpertise = x.DoctorExpertises.FirstOrDefault() select new DoctorListItemDTO { Id = x.Id, FullName = lang == Lang.KU ? x.Person.FullName_Ku : lang == Lang.AR ? x.Person.FullName_Ar : x.Person.FullName, Avatar = x.Person.RealAvatar, ExpertiseCategory = firstExpertise != null ? lang == Lang.AR ? firstExpertise.Expertise.ExpertiseCategory.Name_Ar : lang == Lang.KU ? firstExpertise.Expertise.ExpertiseCategory.Name_Ku : firstExpertise.Expertise.ExpertiseCategory.Name : "", Address = lang == Lang.KU ? x.ShiftCenter.Address_Ku : lang == Lang.AR ? x.ShiftCenter.Address_Ar : x.ShiftCenter.Address, AverageRating = x.AverageRating != null ? (double)Math.Round((decimal)x.AverageRating, 2) : 5, CenterServiceId = shiftCenterService?.Id, Service = shiftCenterService == null ? "" : lang == Lang.KU ? shiftCenterService.Service.Name_Ku : lang == Lang.AR ? shiftCenterService.Service.Name_Ar : shiftCenterService.Service.Name, ReservationType = x.ReservationType, CenterType = x.ShiftCenter.Type, // TODO: Reminder => Find Offers Too in this method (FindFirstDateEmptyTimePeriodsFromNow) TimePeriods = shiftCenterService == null ? new DoctorTimePeriods() : _doctorServiceManager.FindFirstDateEmptyTimePeriodsFromNow(x, shiftCenterService), ConsultancyEnabled = x.ConsultancyEnabled, CanRequestTurn = x.ServiceSupplyInfo != null && x.ServiceSupplyInfo.Description.Contains("#Requested") }).ToList(); var result = new DoctorsResultDTO { TotalCount = totalCount, Doctors = doctors }; return(result); }