public async Task<FdpFeatureMapping> CopyFdpFeatureMappingToDocument(FdpFeatureMapping fdpFeatureMapping, int targetDocumentId)
 {
     return await Task.FromResult(_featureDataStore.FdpFeatureMappingCopy(fdpFeatureMapping, targetDocumentId));
 }
        public FdpFeatureMapping FdpFeatureMappingCopy(FdpFeatureMapping featureMappingToCopy, int targetDocumentId)
        {
            FdpFeatureMapping retVal = new EmptyFdpFeatureMapping();
            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();

                    para.Add("@FdpFeatureMappingId", featureMappingToCopy.FdpFeatureMappingId, DbType.Int32);
                    para.Add("@TargetDocumentId", targetDocumentId, DbType.Int32);
                    para.Add("@CDSId", CurrentCDSID, DbType.String);

                    var rows = conn.Execute("Fdp_FeatureMapping_Copy", para, commandType: CommandType.StoredProcedure);

                    retVal = FdpFeatureMappingGet(new FeatureMappingFilter { FeatureMappingId = featureMappingToCopy.FdpFeatureMappingId });
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }
            return retVal;
        }
 public async Task<FdpFeatureMapping> DeleteFdpFeatureMapping(FdpFeatureMapping featureMappingToDelete)
 {
     return await Task.FromResult(_featureDataStore.FdpFeatureMappingDelete(featureMappingToDelete));
 }
        public FdpFeatureMapping FdpFeatureMappingDelete(FdpFeatureMapping featureMappingToDelete)
        {
            FdpFeatureMapping retVal = new EmptyFdpFeatureMapping();
            using (IDbConnection conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@FdpFeatureMappingId", featureMappingToDelete.FdpFeatureMappingId, DbType.Int32);
                    para.Add("@CDSId", CurrentCDSID, DbType.String);

                    var results = conn.Query<FdpFeatureMapping>("Fdp_FeatureMapping_Delete", para, commandType: CommandType.StoredProcedure);
                    if (results.Any())
                    {
                        retVal = results.First();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }
            return retVal;
        }
        public FdpFeatureMapping FeatureMappingSave(FdpFeatureMapping featureMapping)
        {
            FdpFeatureMapping retVal = new EmptyFdpFeatureMapping();
            using (IDbConnection conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = DynamicParameters.FromCDSId(CurrentCDSID);
                    para.Add("@ImportFeatureCode", featureMapping.ImportFeatureCode, DbType.String);
                    para.Add("@DocumentId", featureMapping.DocumentId, DbType.Int32);
                    para.Add("@FeatureId", featureMapping.FeatureId, DbType.Int32);
                    para.Add("@FeaturePackId", featureMapping.FeaturePackId, DbType.Int32);

                    var results = conn.Query<FdpFeatureMapping>("Fdp_FeatureMapping_Save", para, commandType: CommandType.StoredProcedure);
                    if (results.Any())
                    {
                        retVal = results.First();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }
            return retVal;
        }
 public async Task<ImportError> MapFeature(ImportQueueFilter filter, FdpFeatureMapping featureMapping)
 {
     var task = await Task.FromResult(_featureDataStore.FeatureMappingSave(featureMapping));
     return await Task.FromResult(_importDataStore.ImportErrorGet(filter));
 }
        public async Task<ActionResult> MapMissingFeature(ImportExceptionParameters parameters)
        {
            var filter = ImportQueueFilter.FromExceptionId(parameters.ExceptionId.Value);
            var importView = await GetModelFromParameters(parameters);
            var feature = importView.AvailableFeatures
                .First(f => f.FeatureCode.Equals(parameters.FeatureCode, StringComparison.InvariantCultureIgnoreCase));

            var featureMapping = new FdpFeatureMapping()
            {
                ImportFeatureCode = parameters.ImportFeatureCode,
                ProgrammeId = parameters.ProgrammeId.GetValueOrDefault(),
                Gateway = parameters.Gateway,
                FeatureId = feature.FeatureId,
                FeaturePackId = feature.FeaturePackId
            };
            importView.CurrentException = await DataContext.Import.MapFeature(filter, featureMapping);
            await DeactivateException(importView.CurrentException);
            await ReProcessException(importView.CurrentException);

            return Json(JsonActionResult.GetSuccess(), JsonRequestBehavior.AllowGet);
        }
        public async Task<ActionResult> MapOxoFeature(ImportExceptionParameters parameters)
        {
            var filter = ImportQueueFilter.FromExceptionId(parameters.ExceptionId.GetValueOrDefault());

            var feature = FdpFeature.FromIdentifier(parameters.FeatureIdentifier);
            var importView = await GetModelFromParameters(parameters);

            var importFeatures = (IEnumerable<string>)TempData["MapOxoFeature"];

            foreach (var importFeature in importFeatures)
            {
                var featureMapping = new FdpFeatureMapping()
                {
                    ImportFeatureCode = importFeature,
                    DocumentId = parameters.DocumentId.GetValueOrDefault(),
                    ProgrammeId = parameters.ProgrammeId.GetValueOrDefault(),
                    Gateway = parameters.Gateway,
                    FeatureCode = feature.FeatureCode
                };
                if (feature.FeaturePackId.HasValue)
                {
                    featureMapping.FeaturePackId = feature.FeaturePackId;
                }
                else
                {
                    featureMapping.FeatureId = feature.FeatureId;
                }

                await DataContext.Import.MapFeature(filter, featureMapping);
            }
            await DeactivateException(importView.CurrentException);
            await ReProcessException(importView.CurrentException);

            return Json(JsonActionResult.GetSuccess(), JsonRequestBehavior.AllowGet);
        }