Example #1
0
        public IActionResult MassConvert(decimal numIn)
        {
            IMassConversions gToK = new GramToKilogram();
            IMassConversions kToG = new KilogramToGram();
            IMassConversions gToO = new GramToOunce();
            IMassConversions oToG = new OunceToGram();
            IMassConversions gToP = new GramToPound();
            IMassConversions pToG = new PoundToGram();
            IMassConversions pToO = new PoundToOunce();
            IMassConversions oToP = new OunceToPounds();
            IMassConversions kToO = new KilogramToOunce();
            IMassConversions oToK = new OunceToKilogram();
            IMassConversions pToK = new PoundToKilogram();
            IMassConversions kToP = new KilogramToPound();

            ViewData["NumInput"] = numIn;
            ViewData["OtoL"]     = Math.Round(oToP.GetMass(numIn), 2);
            ViewData["LtoO"]     = Math.Round(pToO.GetMass(numIn), 2);
            ViewData["OtoG"]     = Math.Round(oToG.GetMass(numIn), 2);
            ViewData["GtoO"]     = Math.Round(gToO.GetMass(numIn), 2);
            ViewData["OtoK"]     = Math.Round(oToK.GetMass(numIn), 2);
            ViewData["KtoO"]     = Math.Round(kToO.GetMass(numIn), 2);
            ViewData["LtoG"]     = Math.Round(pToG.GetMass(numIn), 2);
            ViewData["GtoL"]     = Math.Round(gToP.GetMass(numIn), 2);
            ViewData["LtoK"]     = Math.Round(pToK.GetMass(numIn), 2);
            ViewData["KtoL"]     = Math.Round(kToP.GetMass(numIn), 2);
            ViewData["GtoK"]     = Math.Round(gToK.GetMass(numIn), 2);
            ViewData["KtoG"]     = Math.Round(kToG.GetMass(numIn), 2);

            return(View());
        }
Example #2
0
        public decimal GetMass(string type, decimal massIn)
        {
            switch (type)
            {
            case "g2k":
                return(GramToKilogram.Convert(massIn));

            case "k2g":
                return(KilogramToGram.Convert(massIn));

            case "g2o":
                return(GramToOunce.Convert(massIn));

            case "o2g":
                return(OunceToGram.Convert(massIn));

            case "g2p":
                return(GramToPound.Convert(massIn));

            case "p2g":
                return(PoundToGram.Convert(massIn));

            case "k2o":
                return(KilogramToOunce.Convert(massIn));

            case "o2k":
                return(OunceToKilogram.Convert(massIn));

            case "k2p":
                return(KilogramToPound.Convert(massIn));

            case "p2k":
                return(PoundToKilogram.Convert(massIn));

            case "p2o":
                return(PoundToOunce.Convert(massIn));

            case "o2p":
                return(OunceToPounds.Convert(massIn));

            default:
                return(massIn);
            }
        }