示例#1
0
        public IActionResult ConvertMass(ConverterViewModel model)  //Create a convertwhatever cshtml
        {
            switch (model.ConversionType)
            {
            case "OtoP":
                var OtoP = new OuncetoPoundConverter();
                model.ConvertedValue = OtoP.OuncetoPound(model.ValuetoConvert);
                break;

            case "OtoG":
                var OtoG = new OuncetoGramConverter();
                model.ConvertedValue = OtoG.OuncetoGram(model.ValuetoConvert);
                break;

            case "KtoO":
                var KtoO = new KilogtoOunceConverter();
                model.ConvertedValue = KtoO.KilogtoOunce(model.ValuetoConvert);
                break;

            case "PtoG":
                var PtoG = new PoundtoGramConverter();
                model.ConvertedValue = PtoG.PoundtoGram(model.ValuetoConvert);
                break;

            default:
                break;
            }
            return(View(model));
        }
示例#2
0
        public decimal OtoG(string type, string unitvalue)
        {
            decimal v = Convert.ToDecimal(unitvalue);
            OuncetoGramConverter o = new OuncetoGramConverter();
            decimal result         = o.OuncetoGram(v);

            return(result);
        }