public ActionResult CalculateResistorValue(UserSelectedColorCodes userSelectedColorCodes)
 {
     try
     {
         long calculatedresult = ResistorValueCalculator.CalculateResistorValue(userSelectedColorCodes.BandA, userSelectedColorCodes.BandB,
                                                                                userSelectedColorCodes.BandC, userSelectedColorCodes.BandD);
         var resulttolerance = ResistorValueCalculator.GetTolerance(userSelectedColorCodes.BandD);
         return(Json(new { Result = $"Result : { calculatedresult } Ωs +/- { resulttolerance } %" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(new { Result = $"Error in Processing Request" }, JsonRequestBehavior.AllowGet));
     }
 }
 public JsonResult CalculateResistorValue(ResistorValueModel calcModel)
 {
     if (Enum.IsDefined(typeof(BandAColors), calcModel.bandAColor) &&
         Enum.IsDefined(typeof(BandBColors), calcModel.bandBColor) &&
         Enum.IsDefined(typeof(BandCColors), calcModel.bandCColor) &&
         Enum.IsDefined(typeof(BandDColors), calcModel.bandDColor))
     {
         try
         {
             int result = resistorValueCalculator.CalculateResistorValue(calcModel.bandAColor.ToString(), calcModel.bandBColor.ToString(),
                                                                         calcModel.bandCColor.ToString(), calcModel.bandDColor.ToString());
             double tolerance = resistorValueCalculator.GetTolerance(calcModel.bandDColor.ToString());
             return(Json(new { Result = $"Resistor value: { result } Ohms +/- { tolerance } %" }, JsonRequestBehavior.AllowGet));
         }
         catch (Exception)
         {
             return(Json(new { Result = $"An error occured while processing the request." }, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         return(Json(new { Result = "One or more of the input color code is invalid" }, JsonRequestBehavior.AllowGet));
     }
 }