コード例 #1
0
        public ISalaryPolicy GetSalaryPolicy(SoftwareEngineerType softwareEngineerType)
        {
            switch (softwareEngineerType)
            {
            case SoftwareEngineerType.Programmer:
                return(programmerSalaryPolicy);

            case SoftwareEngineerType.Tester:
                return(testerSalaryPolicy);

            default: throw new NotSupportedException($"Cannot find SalaryPolicy for software developer - {softwareEngineerType}");
            }
        }
        public async Task <IHttpActionResult> GetRecommendedSalary(SoftwareEngineerType engineerType, byte workExperianceInYears)
        {
            Salary salary = null;

            try
            {
                salary = await salaryPolicyFactory.GetSalaryPolicy(engineerType).RecommendSalaryAsync(workExperianceInYears);
            }
            catch (ProffessionalExperianceTooLowException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (NotSupportedException ex)
            {
                return(BadRequest(ex.Message));
            }

            if (salary == null)
            {
                return(BadRequest());
            }

            return(Ok(salary));
        }