public async Task <ICommandExit> Handler(UpdateNurseCommand command) { Nurse nurse = await _nurseRepository.GetById(command.Id); nurse.UpdateNurse(command.Name, command.CPF, command.BirthDate, command.Coren, command.Id_Hospital); if (Invalid) { return(new CommandExit(false, "Erro ao cadastrar Nurse", nurse)); } await Task.Factory.StartNew(() => { _nurseRepository.Update(nurse); }); return(new CommandExit(true, "Atualização Realizado Com Sucesso", nurse)); }
public async Task <ICommandResult> Handler(UpdateNurseCommand command) { command.Validate(); if (!command.Valid) { return(new GenericCommandResult(false, "Ops, parece que algo está errado!", command.Notifications)); } var nurse = await _nurseRepository.GetById(command.Id); nurse.updateNurse(command.Name, command.CPF, command.Coren, command.DateBirth); if (nurse.Invalid) { return(new GenericCommandResult(false, "ocoreu algum erro", command.Notifications)); } await _nurseRepository.Update(nurse); return(new GenericCommandResult(true, "Dados do Enfermeiro atualizado", nurse)); }
public async Task <IActionResult> GetById(Guid id, [FromServices] INurseRepository repository) { var result = await repository.GetById(id); return(Ok(_mapper.Map <NurseViewModel>(result))); }
public Nurse GetNurse(string id) { return(_repository.GetById(id)); }
public Nurse GetById(Guid id) { var Nurse = _repository.GetById(id); return(Nurse); }