public ICommandResult Handle(CreateNurseCommand command) { command.Validate(); if (command.Invalid) { AddNotifications(command); return(new CommandResult(false, command.Notifications.Messages(), command)); } Nurse nurse = new Nurse(command.FullName, command.CpfNumber, command.Coren, command.BirthDate.Value, command.DocumentType); nurse.SetHospitalId(command.HospitalId); AddNotifications(nurse); if (Invalid) { return(new CommandResult(false, nurse.Notifications.Messages(), command)); } _nurseRepository.Add(nurse); _uow.Commit(); return(new CommandResult(true, "Sucesso!", nurse)); }
public ICommandResult Post([FromBody] CreateNurseCommand value) { var result = _handler.Handle(value); return(result); }
public async Task <IActionResult> Create([FromBody] CreateNurseCommand command, [FromServices] NurseHandler handler) { return(Ok(await handler.Handler(command))); }
public async Task <ICommandExit> Post([FromBody] CreateNurseCommand createNurseCommand) { var response = await _commandHandlerNurse.Handler(createNurseCommand); return(response); }