Example #1
0
        /// <summary>
        /// Handles the request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="response">The response.</param>
        protected override void HandleRequest(
            GetAllProgramEnrollmentsByClinicalCaseRequest request, GetAllProgramEnrollmentsByClinicalCaseResponse response)
        {
            var clinicalCaseKey = request.ClinicalCaseKey;

            var programEnrollments = _programEnrollmentRepository.GetProgramEnrollmentsByClinicalCase(clinicalCaseKey);

            var programEnrollmentDtos = Mapper.Map <IList <ProgramEnrollment>, IList <ProgramEnrollmentDto> > (
                programEnrollments);

            response.ProgramEnrollmentDtos = programEnrollmentDtos;
        }
        /// <summary>
        /// Handles the request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="response">The response.</param>
        protected override void HandleRequest(DeleteProgramEnrollmentRequest request, DeleteProgramEnrollmentResponse response)
        {
            var programEnrollment = _programEnrollmentRepository.GetByKey(request.ProgramEnrollmentKey);

            if (programEnrollment != null)
            {
                _programEnrollmentFactory.DestroyProgramEnrollment(programEnrollment);

                if (Success)
                {
                    FlushSession();

                    var programEnrollments =
                        _programEnrollmentRepository.GetProgramEnrollmentsByClinicalCase(programEnrollment.ClinicalCase.Key);
                    var dtos = Mapper.Map <IList <ProgramEnrollment>, IList <ProgramEnrollmentDto> > (programEnrollments);
                    response.ProgramEnrollmentDtos = dtos;
                }
            }
        }