Exemplo n.º 1
0
        public void GetRolesTest()
        {
            GetRolesCommand getRolesCommand = new GetRolesCommand();

            getRolesCommand.Execute();
            var roles = getRolesCommand.GetResult();

            //var roles = RoleRepository.GetRoles();
            Assert.AreEqual(5, roles.Count);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetAll([FromForm] GetRolesCommand command)
        {
            var result = await _handler.Handler(command);

            if (result.Succeeded)
            {
                result.Message = _localizer.GetString("ROLE_FOUND").Value;
                return(Ok(result));
            }
            result.Message = _localizer.GetString("ROLE_NOT_FOUND").Value;
            return(NotFound(result));
        }
Exemplo n.º 3
0
        public ActionResult <IEnumerable <Role> > GetRoles()
        {
            var roles    = new List <Role>();
            var rolesDTO = new List <RoleDTO>();

            try
            {
                //  _logger.LogInformation("Ejecutando el Comando GetRolesCommand()");
                GetRolesCommand command = CommandFactory.CreateGetRolesCommand();
                command.Execute();
                //  _logger.LogInformation("Ejecutado el Comando GetRolesCommand()");
                roles = command.GetResult();
                RoleMapper mapper = new RoleMapper();
                rolesDTO = mapper.CreateDTOList(roles);
            }
            catch (DatabaseException e)
            {
                // _logger.LogError("BadRequest: ", e);
                return(BadRequest("Error al Obtener Roles"));
            }

            return(Ok(rolesDTO));
        }