public async Task <IActionResult> AddSolution(int assetId, [FromBody] AddSolutionRequest request)
        {
            var message = mapper.Map <AddSolutionRequest, AddSolution>(request);

            message.AssetId = assetId;

            var model = await mediator.Send(message);

            return(Created("", model));
        }
        public async Task <IActionResult> AddSolutions(
            [FromBody] AddSolutionRequest request)
        {
            if (await appsService.IsRequestValidOnThisLicense(
                    request.AppId,
                    request.License,
                    request.RequestorId))
            {
                if (request.Limit <= 1000)
                {
                    var result = await solutionService.AddSolutions(request.Limit);

                    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.StatusCode400(
                                   string.Format(
                                       "The Amount Of Solutions Requested, {0}, Exceeds The Service's 1,000 Limit",
                                       request.Limit.ToString())
                                   )));
                }
            }
            else
            {
                return(BadRequest(ControllerMessages.InvalidLicenseRequestMessage));
            }
        }
Example #3
0
        public async Task Setup()
        {
            context = await TestDatabase.GetDatabaseContext();

            mockSolutionsService = new MockSolutionsService(context);
            mockAppsService      = new MockAppsService(context);

            baseRequest = new BaseRequest();

            solutionRequest = new SolutionRequest()
            {
                FirstRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                },
                SecondRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                },
                ThirdRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                },
                FourthRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                },
                FifthRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                },
                SixthRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                },
                SeventhRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                },
                EighthRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                },
                NinthRow = new List <int> {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                }
            };

            addSolutionRequest = new AddSolutionRequest()
            {
                Limit = 1000
            };

            invalidAddSolutionRequest = new AddSolutionRequest()
            {
                Limit = 1001
            };

            sutSuccess = new SolutionsController(
                mockSolutionsService.SolutionsServiceSuccessfulRequest.Object,
                mockAppsService.AppsServiceSuccessfulRequest.Object);

            sutFailure = new SolutionsController(
                mockSolutionsService.SolutionsServiceFailedRequest.Object,
                mockAppsService.AppsServiceSuccessfulRequest.Object);

            sutSolvedFailure = new SolutionsController(
                mockSolutionsService.SolutionsServiceSolveFailedRequest.Object,
                mockAppsService.AppsServiceSuccessfulRequest.Object);
        }