예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userIdString"></param>
        /// <param name="professionalIdToGetAppointmentsFor">Use a blank string if the user is the pro</param>
        /// <param name="dateTimeStartInclusive"></param>
        /// <param name="dateTimeEndExclusive"></param>
        /// <returns></returns>
        public List <AppointmentForProUiDto> GetUiDto_AppointmentsForProfessionalOrEmployee(string userIdString, string professionalIdToGetAppointmentsFor, DateTime dateTimeStartInclusive, DateTime dateTimeEndExclusive, bool includeCancelled = false)
        {
            Guid userId = GuidHelper.GetGuid(userIdString);
            Guid targetProfessionalId = GuidHelper.GetGuid(professionalIdToGetAppointmentsFor);
            List <Appointment>            proAppointments = new List <Appointment>();
            List <AppointmentForProUiDto> returnValue     = new List <AppointmentForProUiDto>();

            // Does the pro have access?
            var hasAccess = _accessQueries.DoesUserProfessionalHaveAccessToProfessional_Appointments(userId, targetProfessionalId);

            // If the user has access, get the appointments.
            if (hasAccess == true)
            {
                proAppointments = GetAppointmentsForProfessionalId(targetProfessionalId, dateTimeStartInclusive, dateTimeEndExclusive, includeCancelled);
            }

            if (proAppointments != null && proAppointments.Any())
            {
                foreach (var appt in proAppointments)
                {
                    AppointmentForProUiDto uiRow = _mapper.Map <Appointment, AppointmentForProUiDto>(appt);
                    // Remember to udpate the UI properties!
                    uiRow.FillAdditionalUiProperties();
                    uiRow.ProfessionalId = appt.Professional.ProfessionalId;
                    returnValue.Add(uiRow);
                }
            }

            return(returnValue);
        }
예제 #2
0
        /// <summary>
        /// Get the appointment to view/update
        /// </summary>
        /// <param name="userIdString"></param>
        /// <param name="professionalIdToGetAppointmentFor">Use a blank string if the user is the pro</param>
        /// <param name="appointmentId"></param>
        /// <returns></returns>
        public AppointmentForProUiDto GetUiDto_AppointmentByIdForProfessionalOrEmployee(string userIdString, string professionalIdToGetAppointmentFor, Guid appointmentId, bool includeCancelled = false)
        {
            AppointmentForProUiDto uiDto = null;
            Guid userId = GuidHelper.GetGuid(userIdString);
            Guid targetProfessionalId = GuidHelper.GetGuid(professionalIdToGetAppointmentFor);

            var hasAccess = _accessQueries.DoesUserProfessionalHaveAccessToProfessional_Appointments(userId, targetProfessionalId);

            if (hasAccess)
            {
                var appointment = _unitOfWork.AppointmentsRepository.Get(i => i.Professional.ProfessionalId == targetProfessionalId && i.AppointmentId == appointmentId && (includeCancelled || i.IsCancelled == false)).FirstOrDefault();
                if (appointment != null)
                {
                    uiDto = _mapper.Map <Appointment, AppointmentForProUiDto>(appointment);
                    uiDto.ProfessionalId = appointment.Professional.ProfessionalId;
                    uiDto.FillAdditionalUiProperties();
                }
            }

            return(uiDto);
        }