コード例 #1
0
        public async Task <ActionResult <SudokuSolution> > GetSolution(
            int id,
            [FromBody] BaseRequest request,
            [FromQuery] bool fullRecord = true)
        {
            if (await appsService.IsRequestValidOnThisLicense(
                    request.AppId,
                    request.License,
                    request.RequestorId))
            {
                var result = await solutionService.GetSolution(id, fullRecord);

                if (result.Success)
                {
                    result.Message = ControllerMessages.StatusCode200(result.Message);

                    return(Ok(result));
                }
                else
                {
                    result.Message = ControllerMessages.StatusCode404(result.Message);

                    return(NotFound(result));
                }
            }
            else
            {
                return(BadRequest(ControllerMessages.InvalidLicenseRequestMessage));
            }
        }
コード例 #2
0
        public async Task <ActionResult <Difficulty> > PostDifficulty(
            [FromBody] CreateDifficultyRequest request)
        {
            if (await appsService.IsRequestValidOnThisLicense(
                    request.AppId,
                    request.License,
                    request.RequestorId))
            {
                var result = await difficultiesService
                             .CreateDifficulty(request.Name, request.DisplayName, request.DifficultyLevel);

                if (result.Success)
                {
                    result.Message = ControllerMessages.StatusCode201(result.Message);

                    return(StatusCode((int)HttpStatusCode.Created, result));
                }
                else
                {
                    result.Message = ControllerMessages.StatusCode404(result.Message);

                    return(NotFound(result));
                }
            }
            else
            {
                return(BadRequest(ControllerMessages.InvalidLicenseRequestMessage));
            }
        }
コード例 #3
0
        public async Task<ActionResult<Role>> PostRole(
            [FromBody] CreateRoleRequest request)
        {
            if (await appsService.IsRequestValidOnThisLicense(
                request.AppId,
                request.License,
                request.RequestorId))
            {
                var result = await rolesService
                    .CreateRole(request.Name, request.RoleLevel);

                if (result.Success)
                {
                    result.Message = ControllerMessages.StatusCode201(result.Message);

                    return StatusCode((int)HttpStatusCode.Created, result);
                }
                else
                {
                    result.Message = ControllerMessages.StatusCode404(result.Message);

                    return NotFound(result);
                }
            }
            else
            {
                return BadRequest(ControllerMessages.InvalidLicenseRequestMessage);
            }
        }
コード例 #4
0
        public async Task PermitValidRequests()
        {
            // Arrange

            // Act
            var result = await sut.IsRequestValidOnThisLicense(appId, license, userId);

            // Assert
            Assert.That(result, Is.True);
        }
コード例 #5
0
        public async Task DenyInvalidLicenseRequests()
        {
            // Arrange
            var invalidLicense = "5CDBFC8F-F304-4703-831B-750A7B7F8531";

            // Act
            var result = await sutAppRepoFailure.IsRequestValidOnThisLicense(appId, invalidLicense, userId);

            // Assert
            Assert.That(result, Is.False);
        }
コード例 #6
0
        public async Task DenyRequestWhereUserIsNotRegisteredToApp()
        {
            // Arrange
            var user = new User()
            {
                Id          = 4,
                UserName    = "******",
                FirstName   = "John",
                LastName    = "Doe",
                NickName    = "Johnny Boy",
                Email       = "*****@*****.**",
                Password    = "******",
                IsActive    = true,
                DateCreated = dateCreated,
                DateUpdated = dateCreated
            };

            // Act
            var result = await sutUserRepoFailure.IsRequestValidOnThisLicense(appId, license, user.Id);

            // Assert
            Assert.That(result, Is.False);
        }