コード例 #1
0
        public IEnumerable <AppointmentAdminViewModel> GetAllNonConfirmedAdminView()
        {
            List <AppointmentViewModel> appointmentRequests = _appointmentsService.GetAllNonConfirmed().ToList();
            HashSet <int> offerIds = appointmentRequests.Select(a => a.offerId).ToHashSet();
            List <AppointmentAdminViewModel> result = new List <AppointmentAdminViewModel>();

            if (appointmentRequests.Count > 0)
            {
                Dictionary <int, OfferViewModel> offers = _offersService.GetManyByIds(offerIds.ToArray(), true);
                appointmentRequests.ForEach(a => a.offer = offers[a.offerId]);
                foreach (var request in appointmentRequests)
                {
                    AppointmentAdminViewModel viewModel = _mapper.Map <AppointmentViewModel, AppointmentAdminViewModel>(request);
                    viewModel.UserInfo = _userService.GetUserPersonalInfo(request.customerId);
                    result.Add(viewModel);
                }
            }
            return(result);
        }