Example #1
0
        public async Task <int> Handle(DesactivarUsuarioCommand request, CancellationToken cancellationToken)
        {
            var model = new Domain.OxiServi.AggregatesModel.UserAggregate.User();

            model.Desactivar(request.idUsuario);
            return(await _userRepository.Desactivar(model));
        }
Example #2
0
        public async Task <int> Handle(UpdateUserCommand request, CancellationToken cancellationToken)
        {
            var model = new Domain.OxiServi.AggregatesModel.UserAggregate.User();

            model.Update(request.idUsuario, request.Nombre, request.Paterno, request.Materno,
                         request.NumDocumento, request.TipoDocumento, request.Telefono, request.Email,
                         request.Contrasena, request.IdRol);
            return(await _userRepository.Update(model));
        }
        public async Task <int> Handle(CreateUserCommand request, CancellationToken cancellationToken)
        {
            var model = new Domain.OxiServi.AggregatesModel.UserAggregate.User();

            model.Create(request.Nombre, request.Paterno, request.Materno, request.NumDocumento, request.TipoDocumento, request.Email, request.Contrasena, request.Telefono, request.IdRol);
            int validation = 0;

            switch (request.TipoDocumento)
            {
            case (int)TipoDocumentoEnum.DNI:
                if (request.NumDocumento.Length == (int)DigitosDocumentoEnum.DNI)
                {
                    validation++;
                }
                else
                {
                    validation = -1;
                }
                break;

            case (int)TipoDocumentoEnum.CARNET_DE_EXTRANJERIA:
                if (request.NumDocumento.Length == 12)
                {
                    validation++;
                }
                else
                {
                    validation = -2;
                }
                break;

            case (int)TipoDocumentoEnum.REG_UNICO_DE_CONTRIBUYENTES:
                if (request.NumDocumento.Length == 11)
                {
                    validation++;
                }
                else
                {
                    validation = -3;
                }
                break;

            case (int)TipoDocumentoEnum.PASAPORTE:
                if (request.NumDocumento.Length == 8)
                {
                    validation++;
                }
                else
                {
                    validation = -4;
                }
                break;

            case (int)TipoDocumentoEnum.PARTIDA_NACIMIENTO:
                if (request.NumDocumento.Length == 8)
                {
                    validation++;
                }
                else
                {
                    validation = -5;
                }
                break;
            }
            if (validation > default(int))
            {
                return(await _userRepository.Create(model));
            }
            else
            {
                return(validation);
            }
        }