Пример #1
0
        public MediatorResponse <EmployerEnquiryViewModel> SubmitGlaEnquiry(EmployerEnquiryViewModel viewModel)
        {
            var validationResult = _validator.Validate(viewModel);

            if (!validationResult.IsValid)
            {
                viewModel = PopulateStaticData(viewModel, true);
                return(GetMediatorResponse(EmployerEnquiryMediatorCodes.SubmitEnquiry.ValidationError, viewModel, validationResult));
            }

            //todo: add other cases..
            SubmitQueryStatus resultStatus = _employerEnquiryProvider.SubmitGlaEnquiry(viewModel);

            //populate reference data
            viewModel = PopulateStaticData(viewModel, true);

            switch (resultStatus)
            {
            case SubmitQueryStatus.Success:
                return(GetMediatorResponse(EmployerEnquiryMediatorCodes.SubmitEnquiry.Success, viewModel, EmployerEnquiryPageMessages.QueryHasBeenSubmittedSuccessfully, UserMessageLevel.Success));

            default:
                return(GetMediatorResponse(EmployerEnquiryMediatorCodes.SubmitEnquiry.Error, viewModel, EmployerEnquiryPageMessages.ErrorWhileQuerySubmission, UserMessageLevel.Error));
            }
        }
Пример #2
0
        public MediatorResponse <EmployerEnquiryViewModel> SubmitEnquiry(EmployerEnquiryViewModel viewModel)
        {
            var validationResult = _validators.Validate(viewModel);

            if (!validationResult.IsValid)
            {
                return(GetMediatorResponse(EmployerEnquiryMediatorCodes.SubmitEnquiry.ValidationError, viewModel, validationResult));
            }

            //todo: add other cases..
            SubmitQueryStatus resultStatus = _employerEnquiryProvider.SubmitEnquiry(viewModel);

            //populate reference data
            viewModel.EmployeesCountList         = GetEmployeeCountTypes();
            viewModel.WorkSectorList             = GetWorkSectorTypes();
            viewModel.PreviousExperienceTypeList = GetPreviousExperienceTypes();
            viewModel.EnquirySourceList          = GetEnquirySourceTypes();
            viewModel.EmployeesCountList         = GetEmployeeCountTypes();
            viewModel.TitleList = GetTitleTypes();

            switch (resultStatus)
            {
            case SubmitQueryStatus.Success:
                return(GetMediatorResponse(EmployerEnquiryMediatorCodes.SubmitEnquiry.Success, viewModel, EmployerEnquiryPageMessages.QueryHasBeenSubmittedSuccessfully, UserMessageLevel.Success));

            default:
                return(GetMediatorResponse(EmployerEnquiryMediatorCodes.SubmitEnquiry.Error, viewModel, EmployerEnquiryPageMessages.ErrorWhileQuerySubmission, UserMessageLevel.Error));
            }
        }
        public void SubmitEnquiryTests(SubmitQueryStatus submitQueryStatus, string mediatorCode, string pageMessage, UserMessageLevel userMessageLevel)
        {
            //Arrange
            string firstname          = "First",
                   lastname           = "Last",
                   companyname        = "companyName",
                   email              = "*****@*****.**",
                   employeeCount      = "100",
                   enquiryDescription = "test query",
                   enquirySource      = "Telephone Call",
                   title              = "Mr",
                   prevExp            = "Yes",
                   position           = "Position",
                   workSector         = "retail",
                   phoneNumber        = "0987654321",
                   mobile             = "1234567890",
                   address1           = "Line1",
                   city                 = "City",
                   postcode             = "Postcode";
            var addressViewModelBuilder =
                new AddressViewModelBuilder().AddressLine1(address1).City(city).Postcode(postcode).Build();

            var employerEnquiryViewModel = new EmployerEnquiryViewModelBuilder().Firstname(firstname).Lastname(lastname).MobileNumber(mobile)
                                           .PhoneNumber(phoneNumber).Position(position).PrevExp(prevExp).Title(title)
                                           .WorkSector(workSector)
                                           .EnquirySource(enquirySource).EnquiryDescription(enquiryDescription).EmployeeCount(employeeCount)
                                           .Email(email).Companyname(companyname)
                                           .Address(addressViewModelBuilder)
                                           .Build();

            var employerProviderMock = new Mock <IEmployerEnquiryProvider>();

            employerProviderMock.Setup(x => x.SubmitEnquiry(It.IsAny <EmployerEnquiryViewModel>())).Returns(submitQueryStatus);

            Mock <IReferenceDataMediator> referenceDataMediator = new Mock <IReferenceDataMediator>();

            referenceDataMediator.Setup(c => c.GetReferenceData(It.IsAny <ReferenceDataTypes>()))
            .Returns(new MediatorResponse <ReferenceDataListViewModel>()
            {
                ViewModel = new ReferenceDataListViewModel()
            });

            var mediator = new EmployerEnquiryMediatorBuilder().With(employerProviderMock).With(referenceDataMediator).Build();

            //Act
            var response = mediator.SubmitEnquiry(employerEnquiryViewModel);

            //Assert
            response.Code.Should().Be(mediatorCode);
            response.Message.Text.Should().Be(pageMessage);
            response.Message.Level.Should().Be(userMessageLevel);
        }