Пример #1
0
        public void Should_Remove_A_Specialty_From_A_Hospital()
        {
            RemoveSpecialtyCommand command = new RemoveSpecialtyCommand()
            {
                HospitalId   = hospitalRepository.hospitals.FirstOrDefault().Id,
                SpecialtylId = specialtyRepository.specialties[0].Id
            };

            Assert.IsNotNull(_handler.Handler(command));
        }
        public ICommandResult Handler(RemoveSpecialtyCommand command)
        {
            Specialty specialty = _specialtyRepository.GetById(command.SpecialtylId);
            Hospital  hospital  = _hospitalRepository.GetById(command.HospitalId);

            hospital.RemoveSpecialty(specialty);
            if (!hospital.IsValid())
            {
                return(null);
            }
            _hospitalRepository.RemoveSpecialty(hospital, command.SpecialtylId);
            return(new StandardHospitalCommandResult(hospital.Id, DateTime.Now));
        }