public ActionResult SaveReorderedIndicators(FormCollection fc, int?currentDomainId, string indicatorOrder) { if (currentDomainId.HasValue) { var indicatorSpecifierStrings = indicatorOrder.Split('¬').ToList(); indicatorSpecifierStrings.RemoveAt(indicatorSpecifierStrings.Count - 1); var sequenceNumber = 1; var areaTypeId = Convert.ToInt32(fc["AreaType"]); var indicatorSpecifiers = IndicatorSpecifierParser.Parse(indicatorSpecifierStrings); foreach (var indicatorSpecifier in indicatorSpecifiers) { var groupings = _reader.GetGroupingsByGroupIdAreaTypeIdIndicatorIdAndSexId(currentDomainId.Value, areaTypeId, indicatorSpecifier.IndicatorId, indicatorSpecifier.SexId); foreach (var grouping in groupings) { grouping.Sequence = sequenceNumber; } _writer.UpdateGroupingList(groupings); sequenceNumber++; } } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(View("ProfilesAndIndicators")); }