public async Task ShouldRaiseError_UsingGetEmployeesOfRoleWithInvalidQueryParameters()
        {
            var getEmployeesOfRole =
                new GetEmployeesOfRole
            {
                RoleID   = new Guid("666456c3-a6c8-4e7a-8be5-9aa0aedb8ec1"),
                Page     = 1,
                PageSize = 20
            };

            await Assert.ThrowsAsync <ArgumentException>(async() => await _employeeQrySvc.Query(getEmployeesOfRole));
        }
        public async Task ShouldGet_EmployeeListItems_UsingGetEmployeesOfRoleQueryParameters()
        {
            var getEmployeesOfRole =
                new GetEmployeesOfRole
            {
                RoleID   = new Guid("cad456c3-a6c8-4e7a-8be5-9aa0aedb8ec1"),
                Page     = 1,
                PageSize = 20
            };

            var result = await _employeeQrySvc.Query(getEmployeesOfRole);

            int resultCount = result.ReadModels.ToList().Count;

            Assert.True(resultCount >= 2);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetRoleMembers(Guid roleId, [FromQuery] PagingParameters pagingParams)
        {
            GetEmployeesOfRole queryParams =
                new GetEmployeesOfRole
            {
                RoleID   = roleId,
                Page     = pagingParams.Page,
                PageSize = pagingParams.PageSize
            };

            try
            {
                var retValue = await _employeeQryReqHdler.Handle <GetEmployeesOfRole>(queryParams, HttpContext, Response);

                return(retValue);
            }
            catch (Exception ex)
            {
                _logger.LogError($"An exception has been thrown: {ex}");
                return(BadRequest(ex.Message));
            }
        }