public IActionResult CheckAnswers(RespondentAnswers data, string sendBtn) { if (sendBtn != null && ModelState.IsValid) { var surveyDetails = _mapper.Map <SurveyDetails>(data); try { _streetLightingDataService.SaveSurveyResponse(surveyDetails); } catch (Exception ex) { // refactor - something better than this. return(Redirect("/Home/Error")); } return(View("Finish")); } return(View()); }
public StreetLightingDomainMapperTests() { var config = new MapperConfiguration(mc => mc.AddProfile(new StreetLightingDomainMapper())); _mapper = config.CreateMapper(); _respondentAnswers = new RespondentAnswers { Name = "nameStub", EmailAddress = "*****@*****.**", Address = new RespondentAddress { AddressLine1 = "nameStub", AddressLine2 = null, City = "cityStub", PostCode = "postCodeStub" }, Satisfied = "yes", Brightness = 1 }; }
public void WhenCheckAnswersInvoked_WithSurveyData_ThenFinishViewReturnedOk() { var answers = new RespondentAnswers { Name = "nameStub", EmailAddress = "*****@*****.**", Address = new RespondentAddress { AddressLine1 = "nameStub", AddressLine2 = null, City = "cityStub", PostCode = "postCodeStub" }, Satisfied = "yes", Brightness = 1 }; var result = _streetLightingController.CheckAnswers(answers, "stubVal") as ViewResult; Assert.Equal("Finish", result.ViewName); }