Exemplo n.º 1
0
        public IActionResult ConvertTemp(ConverterViewModel model)
        {
            switch (model.ConversionType)
            {
            case "CtoF":
                var CtoF = new MyTempetureConverter();
                model.ConvertedValue = CtoF.CelciustoFahrenheit(model.ValuetoConvert);
                break;

            case "CtoK":
                var CtoK = new CtoKConverter();
                model.ConvertedValue = CtoK.CelciustoKelvin(model.ValuetoConvert);
                break;

            case "FtoC":
                var FtoC = new FtoCConverter();
                model.ConvertedValue = FtoC.FahrenheittoCelcius(model.ValuetoConvert);
                break;

            case "FtoK":
                var FtoK = new FtoKConverter();
                model.ConvertedValue = FtoK.FahrenheittoKelvin(model.ValuetoConvert);
                break;

            default:
                break;
            }
            return(View(model));
        }
Exemplo n.º 2
0
        public decimal CtoF(string type, string unitvalue)
        {
            decimal val = Convert.ToDecimal(unitvalue);

            // return $"{type} and {unitvalue}";
            MyTempetureConverter convert = new MyTempetureConverter();
            decimal result = convert.CelciustoFahrenheit(val);

            return(result);
        }