예제 #1
0
        public HttpResponseMessage DeleteEmployee(List <Guid> employeeId)
        {
            //executa validacao sobre tipos basicos
            if (employeeId == null)
            {
                var error = new ErrorState()
                {
                    ErrorCode = GeneralEnumerators.enumValidationErrorCode.InvalidGuid,
                    DeveloperMessageTemplate = "employeeId inválido",
                    DocumentationPath        = "/Usernames",
                    UserMessage = "O Id informado para o colaborador não é válido."
                };

                this.ThrowFormattedApiResponse(error, "EmployeeId");
            }

            try
            {
                Claims claims = new Claims().Values();

                var command = new InactiveEmployeeCommand();
                command.EmployeeListId = employeeId;
                command.DeletedBy      = claims.Values().userSystemId;
                this.bus.Send(command);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (System.Exception e)
            {
                LogManager.Error("Erro ao consultar Colaborador", e);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }
예제 #2
0
        public void Handle(InactiveEmployeeCommand command)
        {
            var repository = this.contextFactory();

            foreach (var EmployeeId in command.EmployeeListId)
            {
                Domain.User user = repository.Get(x => x.IntegrationCode == EmployeeId);
                user.UserStatusId = (byte)GeneralEnumerators.EnumUserStatus.Cancelado;
                //todo: necessario atualizar eventos de workflow e registrar quem executou a operacao

                repository.Update(user);
            }
        }
예제 #3
0
        public HttpResponseMessage DeleteAssociateCompanyUser(Guid EmployeeId)
        {
            #region UserCommand
            try
            {
                var commandInactiveAssociateCompanyUser = new InactiveEmployeeCommand();
                commandInactiveAssociateCompanyUser.IntegrationCode = EmployeeId;
                this.bus.Send(commandInactiveAssociateCompanyUser);

                #endregion

                return(Request.CreateResponse(HttpStatusCode.OK));

                LogManager.Error("Error to delete User");
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error to delete User"));
            }
            catch (Exception e)
            {
                LogManager.Error("Error to delete User");
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }