public ICommandResult Handler(UpdateSpecialtyCommand command) { Specialty specialty = _specialtyRepository.GetById(command.SpecialtyId); specialty.Update(command.Name); if (!specialty.IsValid()) { return(null); } _specialtyRepository.Update(specialty); return(new StandardSpecialtyCommandResult(specialty.Id, DateTime.Now)); }
public ICommandResult Handler(AddSpecialtyCommand command) { Specialty specialty = _specialtyRepository.GetById(command.SpecialtylId); Hospital hospital = _hospitalRepository.GetById(command.HospitalId); hospital.AddSpecialty(specialty); if (!hospital.IsValid()) { return(null); } _hospitalRepository.AddSpecialty(hospital, command.SpecialtylId); return(new StandardHospitalCommandResult(hospital.Id, DateTime.Now)); }
public ICommandResult Handler(CreateDoctorCommand command) { Specialty specialty = _specialtyRepository.GetById(command.SpecialtyId); Document cpf = new Document(command.CPF); Doctor doctor = new Doctor(command.Name, command.CRM, cpf, command.DateOfBirth, specialty); if (!doctor.IsValid()) { return(null); } _doctorRepository.Save(doctor); return(new StandardDoctorCommandResult(doctor.Id, DateTime.Now)); }