Example #1
0
        public virtual ActionResult ReassignIndicator(CustomReassignOutcomeIndicatorModel reassignModel)
        {
            int code = 0;

            try
            {
                OutcomeIndicatorModel indicatorModel = ClientResultsMatrix.FindOneOutcomeIndicatorModel(
                    new OutcomeIndicatorSpecification {
                    OutcomeIndicatorId = reassignModel.OutcomeIndicatorId
                });

                indicatorModel.AccessedByAdministrator = IDBContext.Current.HasRole(Role.RM_ADMINISTRATOR);
                indicatorModel.IsThirdInterval         = reassignModel.IsThirdInterval;
                indicatorModel.IntervalId = reassignModel.IntervalId;

                OutcomeModel currentImpactModel = ClientResultsMatrix.FindOneOutcomeModel(
                    new OutcomeSpecification {
                    OutcomeId = indicatorModel.OutcomeId
                });

                OutcomeModel newImpactModel = ClientResultsMatrix.FindOneOutcomeModel(
                    new OutcomeSpecification {
                    OutcomeId = reassignModel.ImpactId
                });

                if (indicatorModel != null & currentImpactModel != null && newImpactModel != null)
                {
                    ClientResultsMatrix.ReassignIndicator(
                        currentImpactModel,
                        newImpactModel,
                        indicatorModel,
                        IDBContext.Current.UserName);

                    code = 503;
                }
            }
            catch (Exception)
            {
                code = 497;
            }

            _cacheData.Remove(_outcomeIndicatorCacheName, System.Web.Caching.CacheItemRemovedReason.Removed);
            _cacheData.Remove(_outcomesCacheName, System.Web.Caching.CacheItemRemovedReason.DependencyChanged);

            var resultsMatrix = ClientResultsMatrix.FindOneModel(
                new ResultsMatrixSpecification {
                ResultsMatrixId = reassignModel.ResultsMatrixId
            });

            return(RedirectToAction(
                       "Edit",
                       "Outcomes",
                       new
            {
                operationId = resultsMatrix.OperationId,
                resultsMatrixId = resultsMatrix.ResultsMatrixId,
                code = code
            }));
        }
Example #2
0
        public virtual ActionResult Reassign(int resultsMatrixId, int impactId, int impactIndicatorId)
        {
            // Check if the administrator is accessing
            var accessedByAdministrator = IDBContext.Current.HasRole(Role.RM_ADMINISTRATOR);

            // Get results matrix with interval data associated to administrator
            var lightResultModel = ClientResultsMatrix.GetLightResultsMatrixModel(new ResultsMatrixModel()
            {
                ResultsMatrixId = resultsMatrixId, AccessedByAdministrator = accessedByAdministrator
            });

            // Set impact data
            OutcomeModel currentImpact = ClientResultsMatrix.FindOneOutcomeModel(new OutcomeSpecification()
            {
                OutcomeId = impactId
            });

            // Get outcomes
            IDB.MW.Domain.Models.Architecture.ResultMatrix.Outcomes.ResultsMatrixModel resultModel = ClientResultsMatrix.FindOneModel(new ResultsMatrixSpecification()
            {
                ResultsMatrixId = resultsMatrixId
            });

            List <OutcomeModel> outcomes = resultModel.Outcomes;

            // Remove current outcome
            outcomes.RemoveAll(i => i.OutcomeId == impactId);

            // Set reassign model properties
            CustomReassignOutcomeIndicatorModel reassignModel = new CustomReassignOutcomeIndicatorModel()
            {
                Statement               = currentImpact.Statement,
                Definition              = currentImpact.OutcomeIndicators.Where(ii => ii.OutcomeIndicatorId == impactIndicatorId).SingleOrDefault <OutcomeIndicatorModel>().Definition,
                OutcomeIndicatorId      = impactIndicatorId,
                ResultsMatrixId         = lightResultModel.ResultsMatrixId,
                AccessedByAdministrator = accessedByAdministrator,
                IsThirdInterval         = lightResultModel.IsThirdInterval,
                ImpactId   = impactId,
                Outcomes   = outcomes,
                IntervalId = lightResultModel.Interval.IntervalId
            };

            return(PartialView(reassignModel));
        }