示例#1
0
        public ICommandResult Handle(UpdateNurseCommand 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)
            {
                Id = command.Id
            };

            nurse.SetHospitalId(command.HospitalId);

            AddNotifications(nurse);

            if (Invalid)
            {
                return(new CommandResult(false, nurse.Notifications.Messages(), command));
            }

            _nurseRepository.Update(nurse);

            _uow.Commit();

            return(new CommandResult(true, "Sucesso!", nurse));
        }
示例#2
0
        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));
        }
示例#3
0
        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));
        }
示例#4
0
 public void UpdateNurse(Nurse Nurse, string userName)
 {
     Nurse.DateUpdated       = DateTime.Now;
     Nurse.UpdatedByUserName = userName;
     _repository.Update(Nurse);
 }