コード例 #1
0
        /// <summary>
        /// Converts COLResults contract to the domain CostofLiving COLCostBreakDownModel object and couple of fields.
        /// </summary>
        /// <param name="refGeographicIndexContracts">The COLResults contracts.</param>
        /// <returns>COLResponseModel with COLCostBreakDownModel object and couple of fields populated.</returns>
        public static COLResponseModel ToDomainObject(this COLResultsContract colResultsContract)
        {
            var toReturn = new COLResponseModel {
            };

            toReturn.CostBreakDown = new List <COLCostBreakDownModel>();

            toReturn.ComparableSalary           = colResultsContract.ComparableSalary;
            toReturn.PercentageIncomeToMaintain = colResultsContract.IncomeToMaintain;
            toReturn.PercentageIncomeToSustain  = colResultsContract.IncomeToSustain;

            //Housing
            toReturn.CostBreakDown.Add(SetCostBreakDownModel("Housing", colResultsContract.Housing));

            //Food
            toReturn.CostBreakDown.Add(SetCostBreakDownModel("Food", colResultsContract.Groceries));

            //Utilities
            toReturn.CostBreakDown.Add(SetCostBreakDownModel("Utilities", colResultsContract.Utilities));

            //Transportation
            toReturn.CostBreakDown.Add(SetCostBreakDownModel("Transportation", colResultsContract.Transportation));

            //Healthcare
            toReturn.CostBreakDown.Add(SetCostBreakDownModel("Healthcare", colResultsContract.Health));

            //Miscellaneous - not needed/used ny the fromt-end, but it is returned by the SaltService
            //toReturn.CostBreakDown.Add(SetCostBreakDownModel("Miscellaneous", colResultsContract.Miscellaneous));

            return(toReturn);
        }
コード例 #2
0
        public COLResponseModel GetCOLStateList()
        {
            const string logMethodName = ".GetCOLStateList() - ";

            _log.Info(logMethodName + "Begin Method");

            COLResponseModel colResponseModel = null;

            try
            {
                if (_surveyAdapter == null)
                {
                    _log.Error(logMethodName + _surveyAdapterExceptionMessage);
                    throw new SurveyBadDataException("Null adapter in ASA.Web.Services.SurveyService.GetCOLStateList()");
                }
                else
                {
                    colResponseModel = _surveyAdapter.GetCOLStateList();
                }
            }
            catch (Exception ex)
            {
                _log.Error(logMethodName + "Exception => " + ex.ToString());
                throw new SurveyOperationException("Web Survey Service - Exception in ASA.Web.Services.SurveyService.GetCOLStateList()", ex);
            }

            _log.Info(logMethodName + "End Method");
            return(colResponseModel);
        }
コード例 #3
0
        public COLResponseModel GetCOLResults(string cityA, string cityB, string salary)
        {
            const string logMethodName = ".GetCOLResults(string cityA, string cityB, string salary) - ";

            _log.Info(logMethodName + "Begin Method");

            COLResponseModel colResponseModel = null;

            //validate fields required for this request.
            COLRequestModel request = new COLRequestModel();

            if (!String.IsNullOrEmpty(cityA))
            {
                request.CityA = Convert.ToInt32(cityA);
            }
            if (!String.IsNullOrEmpty(cityB))
            {
                request.CityB = Convert.ToInt32(cityB);
            }
            if (!String.IsNullOrEmpty(salary))
            {
                request.Salary = Convert.ToDecimal(salary);
            }

            ASAModelValidator mv = new ASAModelValidator();

            string[] fieldNames = { "CityA", "CityB", "Salary" };
            bool     validModel = mv.Validate(request, fieldNames);

            if (validModel)
            {
                try
                {
                    if (_surveyAdapter == null)
                    {
                        _log.Error(logMethodName + _surveyAdapterExceptionMessage);
                        throw new SurveyBadDataException("Null adapter in ASA.Web.Services.SurveyService.GetCOLUrbanAreaList()");
                    }
                    else
                    {
                        COLResponseModel resultsModel = _surveyAdapter.GetCOLResults(request);
                        colResponseModel = resultsModel;
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(logMethodName + "Exception => " + ex.ToString());
                    throw new SurveyOperationException("Web Survey Service - Exception in ASA.Web.Services.SurveyService.GetCOLUrbanAreaList()", ex);
                }
            }
            else
            {
                colResponseModel           = new COLResponseModel();
                colResponseModel.ErrorList = request.ErrorList.ToList();
            }

            _log.Info(logMethodName + "End Method");
            return(colResponseModel);
        }
コード例 #4
0
        /// <summary>
        /// Gets the CostOfLiving results.
        /// </summary>
        /// <param name="request">The COLRequestModel with the CityA, "CityB and Salary provided.</param>
        /// <returns>COLResponseModel with COLCostBreakDownModel and NeededSalary & percentageSalaryChange</returns>
        /// <exception cref="SurveyOperationException">Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetCOLStateList()</exception>
        public COLResponseModel GetCOLResults(COLRequestModel request)
        {
            const string logMethodName = ".GetCOLResults(COLRequestModel request) - ";

            Log.Info(logMethodName + "Begin Method");

            var colResponseModel = new COLResponseModel();

            try
            {
                colResponseModel = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").GetCOLResults((int)request.CityA, (int)request.CityB, (decimal)request.Salary).ToDomainObject();
            }

            catch (Exception ex)
            {
                Log.Error(logMethodName + "Exception =>" + ex.ToString());
                throw new SurveyOperationException("Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetCOLResults()", ex);
            }

            Log.Info(logMethodName + "End Method");
            return(colResponseModel);
        }
コード例 #5
0
        /// <summary>
        /// Get Cost of Living state list.
        /// </summary>
        /// <returns>COLResponseModel containing the COLStateModel list of States.</returns>
        /// <exception cref="SurveyOperationException">Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetCOLStateList()</exception>
        public COLResponseModel GetCOLStateList()
        {
            const string logMethodName = ".GetCOLStateList() - ";

            Log.Info(logMethodName + "Begin Method");

            var colResponseModel = new COLResponseModel();

            try
            {
                colResponseModel.State = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").GetCOLStates().ToDomainObject();
            }

            catch (Exception ex)
            {
                Log.Error(logMethodName + "Exception =>" + ex.ToString());
                throw new SurveyOperationException("Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetCOLStateList()", ex);
            }

            Log.Info(logMethodName + "End Method");
            return(colResponseModel);
        }