public async Task <ICommandResult> Handler(CreateNurseCommand command) { command.Validate(); if (!command.Valid) { return(new GenericCommandResult(false, "Ops, parece que algo está errado!", command.Notifications)); } var isDocument = await _nurseRepository.DocumentExists(command.CPF); if (isDocument) { return(new GenericCommandResult(false, "Ops, já temos um enfermeio cadastrado com esse CPF", command.Notifications)); } var document = new Document(command.CPF, EDocumentType.CPF); var nurse = new Nurse(command.Name, document, command.Coren, command.DateBirth, command.HospitalId); await _nurseRepository.Create(nurse); return(new GenericCommandResult(true, "Enfermeiro cadastrado", nurse)); }