Exemple #1
0
        public ActionResult ConfirmCopyIndicators(CopyIndicatorsModel cim, List <int> selectedDomainId,
                                                  int selectedAreaTypeId, string indicatorTransferDetails)
        {
            var groupId    = GetSelectedGroupIdUsingProfileKeyDomainAndAreaTypeId(cim.UrlKey, cim.DomainId, cim.AreaTypeId);
            var modelCount = 0;

            var indicatorSpecifierStrings = indicatorTransferDetails.Split(',').ToList();
            var indicatorSpecifiers       = IndicatorSpecifierParser.Parse(indicatorSpecifierStrings);

            foreach (var indicatorSpecifier in indicatorSpecifiers)
            {
                var indicatorId = indicatorSpecifier.IndicatorId;
                var sexId       = indicatorSpecifier.SexId;
                var ageId       = indicatorSpecifier.AgeId;

                // Don't copy if identical indicator (including age and sex Id) already exists in destination.
                if (!_dataAccess.IndicatorGroupingsExist(indicatorId, Convert.ToInt32(selectedDomainId[0]),
                                                         selectedAreaTypeId, Convert.ToInt32(ageId), Convert.ToInt32(sexId)))
                {
                    var currentIndicator = cim.IndicatorsToTransfer[modelCount];

                    _dataAccess.CopyIndicatorToDomain(indicatorId, groupId, cim.AreaTypeId,
                                                      currentIndicator.SexId, currentIndicator.AgeId,
                                                      Convert.ToInt32(selectedDomainId[0]), selectedAreaTypeId, sexId,
                                                      ageId);

                    _dataAccess.LogAuditChange("Indicator " + indicatorId + " copied from [" +
                                               cim.DomainName + " (Area: " + cim.AreaTypeId + ", SexId:" + currentIndicator.SexId +
                                               ", AgeId:" + currentIndicator.AgeId + " )] Into " +
                                               "[" + _reader.GetGroupingMetadataList(selectedDomainId)[0].GroupName +
                                               " (Area: " + selectedAreaTypeId + ", SexId:" + sexId + ", AgeId:" + ageId + " )]",
                                               indicatorId, null, _userName, DateTime.Now, CommonUtilities.AuditType.Copy.ToString());
                }
                modelCount++;
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }