/**
 Parses the URL savedEstimateOldStyle, which is in the old estimation save url
 and sets the according difficulties in model.PreconditionItems and
 model.ComplexityItems and the estimate in model.Estimate.
 **/
 private static void ParseOldStyleUrl(HomeModel model, string savedEstimateOldStyle)
 {
     // The old estimate url schema is:
     var urlScheme = "nnnnPPPPPPPPCCCCCCCC";
     // Where n is the original zero-left-padded estimate value,
     // P is the selected precondition difficulty (0, A, B, C, D)
     // C is the selected complexity difficulty (0, A, B, C, D)
     // Preconditions and complexity have the same order as displayed.
     if (savedEstimateOldStyle.Length == "nnnnPPPPPPPPCCCCCCCC".Length)
     {
         int estimate;
         if (int.TryParse(savedEstimateOldStyle.Substring(0, urlScheme.Count(c => c == 'n')),
                          NumberStyles.HexNumber,
                          CultureInfo.InvariantCulture.NumberFormat,
                          out estimate))
         {
             model.Estimate = estimate;
             int preconditionCount = urlScheme.Count(c => c == 'P');
             Debug.Assert(preconditionCount == model.PreconditionItems.Count);
             for (int i = 0; i < preconditionCount; ++i)
             {
                 model.PreconditionItems[i].SelectedDifficulty = CodeToNumericDifficulty(savedEstimateOldStyle[4 + i]);
             }
             int complexityCount = urlScheme.Count(c => c == 'C');
             Debug.Assert(complexityCount == model.ComplexityItems.Count);
             for (int i = 0; i < complexityCount; ++i)
             {
                 model.ComplexityItems[i].SelectedDifficulty = CodeToNumericDifficulty(savedEstimateOldStyle[4 + preconditionCount + i]);
             }
         }
     }
 }
 // GET: /<controller>/
 public IActionResult Index()
 {
     var model = new HomeModel();
     ViewData.Model = model;
     if (HttpContext.Request.Query.ContainsKey ("e"))
     {
         var savedEstimateOldStyle = HttpContext.Request.Query ["e"];
         ParseOldStyleUrl(model, savedEstimateOldStyle);
     }
     return View();
 }