public IComandResult Handle(UpdateCollaboratorComand comand) { var name = new Name(comand.FirstName, comand.LastName); var document = new Document(comand.Document); var email = new Email(comand.Email); var address = new Address(comand.Street, comand.Number, comand.District, comand.City, comand.Country, comand.ZipCode); var idAdd = _collaboratorRepository.Get(comand.Id).IdAddress; address.Id = idAdd; var phone = new Phone(comand.Phone); var collaborator = new Collaborator(name, document, email, phone, address, comand.Salary, comand.ProjectName, comand.BirthDate, comand.JobTitle) { Id = comand.Id }; AddNotifications(collaborator); AddNotifications(name); AddNotifications(document); AddNotifications(email); AddNotifications(address); AddNotifications(phone); if (IsInvalid()) { return(null); } _collaboratorRepository.Update(collaborator); return(new CreateCollaboratorCommandResult(collaborator.Id, name.ToString(), email.Address)); }
public ResultDto Put([FromBody] UpdateCollaboratorComand Collaborator) { ResultDto resultDto; var result = (CreateCollaboratorCommandResult)_collaboratorHandler.Handle(Collaborator); if (_collaboratorHandler.IsValid()) { resultDto = new ResultDto(_collaboratorHandler.IsValid(), "Usuário atualizado com sucesso", result); } else { resultDto = new ResultDto(_collaboratorHandler.IsValid(), "Não foi possível atualizar o usuário", _collaboratorHandler.Notifications); } return(resultDto); }