public void IndexGet_with_invalid_centreId_param_shows_error() { // Given const int centreId = 7; A.CallTo(() => centresDataService.GetCentreName(centreId)).Returns(null); // When var result = controller.Index(centreId); // Then A.CallTo(() => centresDataService.GetCentreName(centreId)).MustHaveHappened(1, Times.Exactly); result.Should().BeNotFoundResult(); }
public IActionResult Index(int?centreId = null) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Home")); } if (!centreId.HasValue || centresDataService.GetCentreName(centreId.Value) == null) { return(NotFound()); } if (!IsRegisterAdminAllowed(centreId.Value)) { return(RedirectToAction("AccessDenied", "LearningSolutions")); } SetAdminRegistrationData(centreId.Value); return(RedirectToAction("PersonalInformation")); }
private bool CheckCentreIdValid(int?centreId) { return(centreId == null || centresDataService.GetCentreName(centreId.Value) != null); }