public async Task <IActionResult> UpdateDoctor(int doctorId, UpdateDoctorCommand updateDoctorCommand) { updateDoctorCommand.DoctorId = doctorId; await _doctorsService.UpdateDoctor(updateDoctorCommand); return(NoContent()); }
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(); }
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)); }
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)); }
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); }