Пример #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());
        }
Пример #2
0
        public IActionResult MassConvert(decimal massIn)
        {
            var gToK = new GramToKilogram();
            var kToG = new KilogramToGram();
            var gToO = new GramToOunces();
            var oToG = new OuncesToGram();
            var gToP = new GramToPound();
            var pToG = new PoundToGram();
            var pToO = new PoundsToOunces();
            var oToP = new OuncesToPounds();
            var kToO = new KilogramToOunce();
            var oToK = new OuncesToKilogram();
            var pTok = new PoundsToKilogram();
            var kToP = new KilogramToPound();

            ViewData["gToK"] = gToK.Mass(massIn);
            ViewData["kToG"] = kToG.Mass(massIn);
            ViewData["gToO"] = gToO.Mass(massIn);
            ViewData["oToG"] = oToG.Mass(massIn);
            ViewData["gToP"] = gToP.Mass(massIn);
            ViewData["pToG"] = pToG.Mass(massIn);
            ViewData["pToO"] = pToO.Mass(massIn);
            ViewData["oToP"] = oToP.Mass(massIn);
            ViewData["kToO"] = kToO.Mass(massIn);
            ViewData["oToK"] = oToK.Mass(massIn);
            ViewData["pTok"] = pTok.Mass(massIn);
            ViewData["KToP"] = kToP.Mass(massIn);



            return(View());
        }
Пример #3
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);
            }
        }
Пример #4
0
        public IActionResult DoConversion(ConverterViewModel model)
        {
            switch (model.ConversionType)
            {
            //TEMP
            case "CtoF":
                var cToF = new CelsiusToFahrenheit();
                model.ConvertedValue = cToF.Temp(model.ValueToConvert);
                break;

            case "FtoC":
                var FtoC = new FahrenheitToCelsius();
                model.ConvertedValue = FtoC.Temp(model.ValueToConvert);
                break;

            case "CtoK":
                var CtoK = new CelsiusToKelvin();
                model.ConvertedValue = CtoK.Temp(model.ValueToConvert);
                break;

            case "KtoC":
                var KtoC = new KelvinToCelsius();
                model.ConvertedValue = KtoC.Temp(model.ValueToConvert);
                break;

            case "fToK":
                var fToK = new FahrenheitToKelvin();
                model.ConvertedValue = fToK.Temp(model.ValueToConvert);
                break;

            case "kToF":
                var kToF = new KelvinToFahrenheit();
                model.ConvertedValue = kToF.Temp(model.ValueToConvert);
                break;

            //LENGTH
            case "mToF":
                var mToF = new MetersToFeet();
                model.ConvertedValue = mToF.Lengths(model.ValueToConvert);
                break;

            case "fToM":
                var fToM = new FeetToMeters();
                model.ConvertedValue = fToM.Lengths(model.ValueToConvert);
                break;

            case "mtoY":
                var mtoY = new MetersToYard();
                model.ConvertedValue = mtoY.Lengths(model.ValueToConvert);
                break;

            case "ytoM":
                var ytoM = new YardToMeter();
                model.ConvertedValue = ytoM.Lengths(model.ValueToConvert);
                break;

            case "fToY":
                var fToY = new FeetToYards();
                model.ConvertedValue = fToY.Lengths(model.ValueToConvert);
                break;

            case "yToF":
                var yToF = new YardToFeet();
                model.ConvertedValue = yToF.Lengths(model.ValueToConvert);
                break;

            //MASS
            case "gToK":
                var gToK = new GramToKilogram();
                model.ConvertedValue = gToK.Mass(model.ValueToConvert);
                break;

            case "kToG":
                var kToG = new KilogramToGram();
                model.ConvertedValue = kToG.Mass(model.ValueToConvert);
                break;

            case "gToO":
                var gToO = new GramToOunces();
                model.ConvertedValue = gToO.Mass(model.ValueToConvert);
                break;

            case "oToG":
                var oToG = new OuncesToGram();
                model.ConvertedValue = oToG.Mass(model.ValueToConvert);
                break;

            case "gToP":
                var gToP = new GramToPound();
                model.ConvertedValue = gToP.Mass(model.ValueToConvert);
                break;

            case "pToG":
                var pToG = new PoundToGram();
                model.ConvertedValue = pToG.Mass(model.ValueToConvert);
                break;

            case "pToO":
                var pToO = new PoundsToOunces();
                model.ConvertedValue = pToO.Mass(model.ValueToConvert);
                break;

            case "oToP":
                var oToP = new OuncesToPounds();
                model.ConvertedValue = oToP.Mass(model.ValueToConvert);
                break;

            case "kToO":
                var kToO = new KilogramToOunce();
                model.ConvertedValue = kToO.Mass(model.ValueToConvert);
                break;

            case "oToK":
                var oToK = new OuncesToKilogram();
                model.ConvertedValue = oToK.Mass(model.ValueToConvert);
                break;

            case "pToK":
                var pToK = new PoundsToKilogram();
                model.ConvertedValue = pToK.Mass(model.ValueToConvert);
                break;

            case "KToP":
                var KToP = new KilogramToPound();
                model.ConvertedValue = KToP.Mass(model.ValueToConvert);
                break;

            default:
                break;
            }
            //the conversion work happen in here
            //cToF.Temp(tempIn);
            return(View(model));
        }