public async Task <ResistorOhmResponse> GetResistorOhmValue(ResistorOhmRequest request)
        {
            ResistorOhmResponse response = new ResistorOhmResponse();

            switch (request.testScenario)
            {
            case TestScenarioEnum.validateBlackBlackBlack:
                response = new ResistorOhmResponse()
                {
                    Ohm     = 0,
                    Success = true
                };
                break;

            case TestScenarioEnum.validateRedOrangeBlack:
                response = new ResistorOhmResponse()
                {
                    Ohm     = 230,
                    Success = true
                };
                break;

            default:
                break;
            }

            return(response);
        }
Пример #2
0
        public async Task <ResistorOhmResponse> GetOhmValue(ResistorOhmRequest request)
        {
            ResistorOhmResponse ohmResponse;

            try
            {
                if (request == null)
                {
                    return(new ResistorOhmResponse()
                    {
                        Success = false,
                        Error = "Bad Request"
                    });
                }

                ohmResponse = await _DataAccess.GetResistorOhmValue(request);
            }
            catch
            {
                ohmResponse = new ResistorOhmResponse()
                {
                    Success = false,
                    Error   = "Service Error"
                };
            }

            return(ohmResponse);
        }
        public async Task <ResistorOhmResponse> GetResistorOhmValue(ResistorOhmRequest request)
        {
            ResistorOhmResponse ohmResponse;

            var response = await _Client.GetAsync("/OhmCalculator/Ohmvalue?bandAColor=" + request.bandAColor.GetHashCode() + "&bandBColor=" + request.bandBColor.GetHashCode() + "&bandCColor=" + request.bandCColor.GetHashCode());

            if (response.IsSuccessStatusCode)
            {
                var strResponse = await response.Content.ReadAsStringAsync();

                ohmResponse         = JsonConvert.DeserializeObject <ResistorOhmResponse>(strResponse);
                ohmResponse.Success = true;
            }
            else
            {
                ohmResponse = new ResistorOhmResponse()
                {
                    Success = false,
                    Error   = "Service Error"
                };
            }

            return(ohmResponse);
        }