private ReorderError AllowReorder(List <dtoReorderGraphActivity> activities, ReorderAction dAction = ReorderAction.Ignore)
        {
            ReorderError result = Service.AllowReorder(activities);

            switch (result)
            {
            case ReorderError.InConflictPredecessorsFound:
            case ReorderError.SummaryWithLinks:
                result = (dAction == ReorderAction.RemoveAllPredecessors || dAction == ReorderAction.RemoveConflictPredecessors) ? ReorderError.None: result;
                break;
            }
            return(result);
        }
        public void ApplyReorder(List <dtoReorderGraphActivity> activities, ReorderAction dAction = ReorderAction.Ignore)
        {
            long idProject = View.IdProject;

            if (IsSessionTimeout())
            {
                return;
            }
            else if (activities.Any())
            {
                activities = Service.AnalyzeActionsForReorder(idProject, activities);
                ReorderError result = AllowReorder(activities, dAction);
                if (result == ReorderError.None)
                {
                    result = Service.ReorderActivities(idProject, activities, dAction);
                }
                switch (result)
                {
                case ReorderError.None:
                    View.DisplayReorderCompleted();
                    //ModuleProjectManagement.ActionType uAction = ModuleProjectManagement.ActionType.ReorderApplied;
                    //switch (dAction) {
                    //    case ReorderAction.RemoveAllPredecessors:
                    //        uAction = ModuleProjectManagement.ActionType.ReorderAppliedWithAllLinksRemoved;
                    //        break;
                    //    case ReorderAction.RemoveConflictPredecessors:
                    //        uAction = ModuleProjectManagement.ActionType.ReorderAppliedWithCyclesInvolvedLinksRemoved;
                    //        break;
                    //}
                    View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ReorderApplied);
                    LoadItems(idProject, dAction);
                    break;

                case ReorderError.ProjectMapChanged:
                    View.DisplayConfirmActions(result, new List <dtoReorderAction>()
                    {
                        new dtoReorderAction()
                        {
                            Action = ReorderAction.ReloadProjectMap
                        }, new dtoReorderAction()
                        {
                            Action = ReorderAction.ReloadProjectMapWithReorderedItems, Selected = true
                        }
                    });
                    View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ReorderProjectMapChanged);
                    LoadItems(idProject, activities, dAction);
                    break;

                case ReorderError.DataAccess:
                    View.DisplayConfirmActions(result);
                    View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ReorderDataSavingErrors);
                    LoadItems(idProject, activities, dAction);
                    break;

                case ReorderError.InConflictPredecessorsFound:
                case ReorderError.SummaryWithLinks:
                    View.DisplayConfirmActions(result, new List <dtoReorderAction>()
                    {
                        new dtoReorderAction(ReorderAction.RemoveConflictPredecessors, true), new dtoReorderAction(ReorderAction.RemoveAllPredecessors)
                    });
                    View.SendUserAction(View.ProjectIdCommunity, CurrentIdModule, idProject, ModuleProjectManagement.ActionType.ReorderCyclesFound);
                    LoadItems(idProject, activities, dAction);
                    break;
                }
            }
            else
            {
                LoadItems(idProject, dAction);
            }
        }