Esempio 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));
        }
Esempio n. 2
0
        public decimal FtoC(string type, string unitvalue)
        {
            decimal       v      = Convert.ToDecimal(unitvalue);
            FtoCConverter cc     = new FtoCConverter();
            decimal       result = cc.FahrenheittoCelcius(v);

            return(result);
        }