Exemplo n.º 1
0
        public async Task <IActionResult> Body(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(RedirectTo(CompositeViewModel.PageId.Home.Value));
            }

            ViewModel.DocumentId = id;

            //Hard coded value - Needs removing upon account, and DSS integration
            var shcDocuments = _skillsHealthCheckService.GetShcDocumentsForUser("200010216");

            if (!shcDocuments.Any())
            {
                return(RedirectTo(CompositeViewModel.PageId.Home.Value));
            }
            var doc = shcDocuments.FirstOrDefault(x => x.DocumentId == ViewModel.DocumentId);

            if (doc == null)
            {
                return(RedirectTo(CompositeViewModel.PageId.Home.Value));
            }

            ViewModel.CreatedAt = doc.CreatedAt;
            return(await base.Body());
        }
Exemplo n.º 2
0
        public async Task WhenShcDocumentsReturnEmpty_ReturnHomeHtml()
        {
            var controller = new ShcDeletedController(_compositeSettings, _authService, _skillsHealthCheckService, _documentService, _config);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            _skillsHealthCheckService.GetShcDocumentsForUser(Arg.Any <string>()).Returns(new List <ShcDocument>());
            var result = await controller.Body("123345") as RedirectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();

            result.Url.Should().Be("~/home");
        }