public bool UpdateStageOrder(List <StageSort> SortArray) { int[] arrStageIds = SortArray.Select(x => x.StageId).ToArray(); List <Stage> stageList = stageRepository.GetAll(r => arrStageIds.Contains(r.StageId)).ToList(); for (int i = 0; i < SortArray.Count(); i++) { for (int j = 0; j < stageList.Count(); j++) { if (stageList[j].StageId == SortArray[i].StageId) { stageList[j].StageOrder = SortArray[i].StageIndex; break; } } } stageRepository.UpdateAll(stageList); return(true); }