Exemple #1
0
        internal Program( Agency agency, string name, DateTime startDate, ProgramCharacteristics programCharacteristics )
            : this()
        {
            Check.IsNotNull ( agency, "Agency is required." );
            Check.IsNotNullOrWhitespace ( name, "Display name is required." );
            Check.IsNotNull ( startDate, "StartDate is required." );
            Check.IsNotNull(programCharacteristics, "ProgramCharacteristics is required.");

            Agency = agency;
            _name = name;
            _startDate = startDate;
            _endDate = null;
            _programCharacteristics = programCharacteristics;
        }
        /// <summary>
        /// Creates the new.
        /// </summary>
        /// <param name="dto">The dto to create new for.</param>
        /// <returns>A <see cref="Rem.Domain.Clinical.ProgramModule.Program"/></returns>
        protected override Program CreateNew(ProgramDto dto)
        {
            Check.IsNotNull(dto.StartDate, "Start Date is required.");

            var agency = _agencyRepository.GetByKey(dto.AgencyKey);

            if (agency == null)
            {
                throw new InvalidOperationException("Agency does not exist");
            }

            var ageGroup               = _mappingHelper.MapLookupField <AgeGroup> (dto.AgeGroup);
            var genderSpecification    = _mappingHelper.MapLookupField <GenderSpecification> (dto.GenderSpecification);
            var treatmentApproach      = _mappingHelper.MapLookupField <TreatmentApproach> (dto.TreatmentApproach);
            var programCategory        = _mappingHelper.MapLookupField <ProgramCategory> (dto.ProgramCategory);
            var programCharacteristics = new ProgramCharacteristics(ageGroup, genderSpecification, treatmentApproach, programCategory);
            var entity = _programFactory.CreateProgram(agency, dto.Name, dto.StartDate.Value, programCharacteristics);

            return(entity);
        }
        /// <summary>
        /// Processes the single aggregate.
        /// </summary>
        /// <param name="dto">The dto to process.</param>
        /// <param name="program">The program.</param>
        /// <returns>A <see cref="System.Boolean"/></returns>
        protected override bool ProcessSingleAggregate(ProgramDto dto, Program program)
        {
            Check.IsNotNull(dto.StartDate, "Start Date is required.");

            var ageGroup               = _mappingHelper.MapLookupField <AgeGroup> (dto.AgeGroup);
            var genderSpecification    = _mappingHelper.MapLookupField <GenderSpecification> (dto.GenderSpecification);
            var treatmentApproach      = _mappingHelper.MapLookupField <TreatmentApproach> (dto.TreatmentApproach);
            var programCategory        = _mappingHelper.MapLookupField <ProgramCategory> (dto.ProgramCategory);
            var programCharacteristics = new ProgramCharacteristics(ageGroup, genderSpecification, treatmentApproach, programCategory);

            var capacityType = _mappingHelper.MapLookupField <CapacityType> (dto.CapacityType);

            program.ReviseProgramCharacteristics(programCharacteristics);
            if (program.Name != dto.Name)
            {
                program.RenameProgram(dto.Name);
            }
            program.RenameDisplayName(dto.DisplayName);
            program.ChangeStartDate(dto.StartDate.Value);
            program.ChangeEndDate(dto.EndDate);
            program.ChangeCapacityType(capacityType);

            return(true);
        }
Exemple #4
0
 /// <summary>
 /// Revises the program characteristics.
 /// </summary>
 /// <param name="programCharacteristics">The program characteristics.</param>
 public virtual void ReviseProgramCharacteristics(ProgramCharacteristics programCharacteristics)
 {
     ProgramCharacteristics = programCharacteristics;
 }
Exemple #5
0
 /// <summary>
 /// Creates the program.
 /// </summary>
 /// <param name="agency">The agency.</param>
 /// <param name="name">The name.</param>
 /// <param name="startDate">The start date.</param>
 /// <param name="programCharacteristics">The program characteristics.</param>
 /// <returns>
 /// A Program.
 /// </returns>
 public Program CreateProgram( Agency agency, string name, DateTime startDate, ProgramCharacteristics programCharacteristics )
 {
     var program = new Program ( agency, name, startDate, programCharacteristics );
     _programRepository.MakePersistent ( program );
     return program;
 }