Exemplo n.º 1
0
        public async Task <IActionResult> UpdateDoctor(int doctorId, UpdateDoctorCommand updateDoctorCommand)
        {
            updateDoctorCommand.DoctorId = doctorId;
            await _doctorsService.UpdateDoctor(updateDoctorCommand);

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task UpdateDoctor(UpdateDoctorCommand updateDoctorCommand)
        {
            var doctorId         = updateDoctorCommand.DoctorId;
            var updatedFirstName = updateDoctorCommand.FirstName;
            var updatedLastName  = updateDoctorCommand.LastName;
            var updatedEmail     = updateDoctorCommand.Email;
            var doctor           = await FindDoctor(doctorId);

            doctor.FirstName = updatedFirstName;
            doctor.LastName  = updatedLastName;
            doctor.Email     = updatedEmail;
            await _context.SaveChangesAsync();
        }
Exemplo n.º 3
0
        public ICommandResult Handler(UpdateDoctorCommand command)
        {
            Specialty specialty = _specialtyRepository.GetById(command.SpecialtyId);
            Document  cpf       = new Document(command.CPF);
            Doctor    doctor    = _doctorRepository.GetById(command.DoctorId);

            doctor.Update(command.Name, command.CRM, cpf, command.DateOfBirth, specialty);
            if (!doctor.IsValid())
            {
                return(null);
            }
            _doctorRepository.Update(doctor);
            return(new StandardDoctorCommandResult(doctor.Id, DateTime.Now));
        }
Exemplo n.º 4
0
        public void Should_Update_A_Doctor()
        {
            UpdateDoctorCommand command = new UpdateDoctorCommand()
            {
                DoctorId    = doctorRepository.doctors[0].Id,
                Name        = "Caciny",
                CPF         = "75317627060",
                CRM         = "330310744",
                DateOfBirth = DateTime.Parse("12/06/1986"),
                SpecialtyId = specialtyRepository.specialties[0].Id
            };

            Assert.IsNotNull(_handler.Handler(command));
        }
Exemplo n.º 5
0
        public Task Handle(UpdateDoctorCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.CompletedTask);
            }

            var doctor = new Doctor(message.DoctorId, message.CRM, message.Person);

            _doctorRepository.Add(doctor);

            if (Commit())
            {
                Bus.RaiseEvent(new DoctorUpdatedEvent(message.DoctorId, message.CRM));
            }

            return(Task.CompletedTask);
        }