Exemplo n.º 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));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> SubmitEmployerEnquiryUnbranded(EmployerEnquiryViewModel model)
        {
            return(await Task.Run <ActionResult>(() =>
            {
                var response = _employerEnquiryMediator.SubmitEnquiry(model);
                ModelState.Clear();

                switch (response.Code)
                {
                case EmployerEnquiryMediatorCodes.SubmitEnquiry.ValidationError:
                    response.ValidationResult.AddToModelState(ModelState, string.Empty);
                    return View("SubmitEmployerEnquiry", "_LayoutNoHeaderFooter", model);

                case EmployerEnquiryMediatorCodes.SubmitEnquiry.Error:
                    SetPageMessage(response.Message.Text, response.Message.Level);
                    return View("SubmitEmployerEnquiry", "_LayoutNoHeaderFooter", model);

                case EmployerEnquiryMediatorCodes.SubmitEnquiry.Success:
                    return RedirectToRoute(EmployerRouteNames.SubmitEmployerEnquiryUnbrandedThankYou);

                default:
                    throw new InvalidMediatorCodeException(response.Code);
                }
            }));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> SubmitEmployerEnquiry(EmployerEnquiryViewModel model)
        {
            return(await Task.Run <ActionResult>(() =>
            {
                var response = _employerEnquiryMediator.SubmitEnquiry(model);
                ModelState.Clear();

                switch (response.Code)
                {
                case EmployerEnquiryMediatorCodes.SubmitEnquiry.ValidationError:
                    response.ValidationResult.AddToModelState(ModelState, string.Empty);
                    return View(model);

                case EmployerEnquiryMediatorCodes.SubmitEnquiry.Error:
                    SetPageMessage(EmployerEnquiryPageMessages.ErrorWhileQuerySubmission, UserMessageLevel.Error);
                    return View(model);

                case EmployerEnquiryMediatorCodes.SubmitEnquiry.Success:
                    SetPageMessage(EmployerEnquiryPageMessages.QueryHasBeenSubmittedSuccessfully);
                    return View("ThankYou");

                default:
                    throw new InvalidMediatorCodeException(response.Code);
                }
            }));
        }
Exemplo n.º 4
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));
            }
        }
Exemplo n.º 5
0
 private EmployerEnquiryViewModel PopulateStaticData(EmployerEnquiryViewModel viewModel, bool isGla)
 {
     viewModel.EmployeesCountList         = GetEmployeeCountTypes();
     viewModel.WorkSectorList             = GetWorkSectorTypes();
     viewModel.PreviousExperienceTypeList = GetPreviousExperienceTypes();
     viewModel.EnquirySourceList          = isGla ? GetGlaEnquirySourceTypes() : GetEnquirySourceTypes();
     viewModel.EmployeesCountList         = GetEmployeeCountTypes();
     viewModel.TitleList            = GetTitleTypes();
     viewModel.EnquiryRelatesToList = GetEnquiryRelatesTo();
     return(viewModel);
 }
Exemplo n.º 6
0
        public MediatorResponse <EmployerEnquiryViewModel> SubmitEnquiry()
        {
            var model = new EmployerEnquiryViewModel
            {
                //Get The various reference data list
                EmployeesCountList         = GetEmployeeCountTypes(),
                WorkSectorList             = GetWorkSectorTypes(),
                PreviousExperienceTypeList = GetPreviousExperienceTypes(),
                TitleList         = GetTitleTypes(),
                EnquirySourceList = GetEnquirySourceTypes()
            };

            return(GetMediatorResponse(EmployerEnquiryMediatorCodes.SubmitEnquiry.Success, model));
        }
Exemplo n.º 7
0
 public SubmitQueryStatus SubmitEnquiry(EmployerEnquiryViewModel employerEnquiryData)
 {
     try
     {
         var employerEnquiry = _employerEnquiryViewModelToDomainMapper.ConvertToDomain(employerEnquiryData);
         _communciationService.SubmitEnquiry(employerEnquiry);
         return(SubmitQueryStatus.Success);
     }
     catch (System.Exception exception)
     {
         //todo: log error using preferred logging mechanism
         return(SubmitQueryStatus.Error);
         //todo: add other cases if there are any
     }
 }
        public SubmitQueryStatus SubmitGlaEnquiry(EmployerEnquiryViewModel employerEnquiryData)
        {
            try
            {
                var result = _employerEnquiryViewModelToDomainMapper.ConvertToDomain(employerEnquiryData);

                var natureOfEnquiry = string.Format("How did you hear about the GLA: {0}\r\n{1}", result.EnquirySource, result.EnquiryDescription);

                var communicationTokens = new[]
                {
                    //common tokens
                    new CommunicationToken(CommunicationTokens.Address1, result.Address.AddressLine1),
                    new CommunicationToken(CommunicationTokens.Address2, result.Address.AddressLine2),
                    new CommunicationToken(CommunicationTokens.Address3, result.Address.AddressLine3),
                    new CommunicationToken(CommunicationTokens.City, result.Address.City),
                    new CommunicationToken(CommunicationTokens.Postcode, result.Address.Postcode),
                    new CommunicationToken(CommunicationTokens.FullAddress, String.Format("{0} {1} {2} {3} {4}", result.Address.AddressLine1, result.Address.AddressLine2, result.Address.AddressLine3, result.Address.City, result.Address.Postcode)),
                    new CommunicationToken(CommunicationTokens.Title, result.Title),
                    new CommunicationToken(CommunicationTokens.Firstname, result.Firstname),
                    new CommunicationToken(CommunicationTokens.Lastname, result.Lastname),
                    new CommunicationToken(CommunicationTokens.Email, result.Email),
                    new CommunicationToken(CommunicationTokens.Fullname, String.Format("{0} {1} {2}", result.Title.ToFirstCharToUpper(), result.Firstname.ToFirstCharToUpper(), result.Lastname.ToFirstCharToUpper())),
                    new CommunicationToken(CommunicationTokens.WorkPhoneNumber, result.WorkPhoneNumber),
                    new CommunicationToken(CommunicationTokens.MobileNumber, result.MobileNumber),
                    new CommunicationToken(CommunicationTokens.Companyname, result.Companyname),
                    new CommunicationToken(CommunicationTokens.Position, result.Position),
                    //Employer enquiry specific tokens
                    new CommunicationToken(CommunicationTokens.EmployeesCount, result.EmployeesCount),
                    new CommunicationToken(CommunicationTokens.EnquiryDescription, natureOfEnquiry),
                    new CommunicationToken(CommunicationTokens.EnquirySource, result.EnquirySource),
                    new CommunicationToken(CommunicationTokens.PreviousExperienceType, result.PreviousExperienceType),
                    new CommunicationToken(CommunicationTokens.WorkSector, result.WorkSector),
                    new CommunicationToken(CommunicationTokens.EnquiryRelatesTo, result.EnquiryRelatesTo)
                };
                //Send email to helpdesk
                _communciationService.SendMessage(MessageTypes.GlaEmployerEnquiry, communicationTokens);
                //Send confirmation email to applicant
                //_communciationService.SendMessage(MessageTypes.GlaEmployerEnquiryConfirmation, communicationTokens);
                return(SubmitQueryStatus.Success);
            }
            catch (System.Exception exception)
            {
                //todo: log error using preferred logging mechanism
                return(SubmitQueryStatus.Error);
            }
        }
Exemplo n.º 9
0
        public EmployerEnquiryViewModel Build()
        {
            var model = new EmployerEnquiryViewModel()
            {
                Firstname              = _firstname,
                Lastname               = _lastname,
                WorkPhoneNumber        = _phoneNumber,
                MobileNumber           = _mobileNumber,
                Position               = _position,
                Companyname            = _companyName,
                Title                  = _title,
                EnquirySource          = _enquirySource,
                Email                  = _email,
                EmployeesCount         = _employeeCount,
                EnquiryDescription     = _enquiryDescription,
                PreviousExperienceType = _prevExp
            };

            return(model);
        }