public static FdpFeature FromIdentifier(string identifier)
 {
     var elements = identifier.Split('|');
     var feature = new FdpFeature();
     if (elements.Length == 2)
     {
         feature.FeatureCode = elements[0];
         if (elements[1].StartsWith("P"))
         {
             feature.FeaturePackId = int.Parse(elements[1].Substring(1));
         }
         else
         {
             feature.FeatureId = int.Parse(elements[1].Substring(1));
             feature.Id = feature.FeatureId.GetValueOrDefault();
         }
     }
     else
     {
         if (elements[0].StartsWith("P"))
         {
             feature.FeaturePackId = int.Parse(elements[0].Substring(1));
         }
         else
         {
             feature.FeatureId = int.Parse(elements[0].Substring(1));
             feature.Id = feature.FeatureId.GetValueOrDefault();
         }
     }
     return feature;
 }
 public OxoFeature(FdpFeature fromFeature)
 {
     DocumentId = fromFeature.DocumentId;
     ProgrammeId = fromFeature.ProgrammeId;
     Gateway = fromFeature.Gateway;
     CreatedOn = fromFeature.CreatedOn;
     CreatedBy = fromFeature.CreatedBy;
     UpdatedOn = fromFeature.UpdatedOn;
     UpdatedBy = fromFeature.UpdatedBy;
     IsActive = fromFeature.IsActive;
     Description = fromFeature.Description;
     FeatureCode = fromFeature.FeatureCode;
     FeatureId = fromFeature.FeatureId;
     FeaturePackId = fromFeature.FeaturePackId;
 }
        // Features and mappings

        public async Task<FdpFeature> DeleteFdpFeature(FdpFeature featureToDelete)
        {
            return await Task.FromResult(_featureDataStore.FdpFeatureDelete(featureToDelete));
        }
 public FdpFeature FdpFeatureSave(FdpFeature feature)
 {
     FdpFeature retVal = new EmptyFdpFeature();
     using (IDbConnection conn = DbHelper.GetDBConnection())
     {
         try
         {
             var para = DynamicParameters.FromCDSId(CurrentCDSID);
             para.Add("@ProgrammeId", feature.ProgrammeId.GetValueOrDefault(), DbType.Int32);
             para.Add("@Gateway", feature.Gateway, DbType.String);
             para.Add("@FeatureCode", feature.FeatureCode, DbType.String);
             para.Add("@FeatureGroupId", feature.FeatureGroupId, DbType.Int32);
             para.Add("@FeatureDescription", feature.BrandDescription, DbType.String);
             
             retVal = conn.Query<FdpFeature>("dbo.Fdp_Feature_Save", para, commandType: CommandType.StoredProcedure).FirstOrDefault();
         }
         catch (Exception ex)
         {
             Log.Error(ex);
             throw;
         }
     }
     return retVal;
 }
 public FdpFeature FdpFeatureDelete(FdpFeature featureToDelete)
 {
     FdpFeature retVal = new EmptyFdpFeature();
     using (IDbConnection conn = DbHelper.GetDBConnection())
     {
         try
         {
             var para = DynamicParameters.FromCDSId(CurrentCDSID);
             para.Add("@FdpFeatureId", featureToDelete.FdpFeatureId.GetValueOrDefault(), DbType.Int32);
             
             retVal = conn.Query<FdpFeature>("dbo.Fdp_Feature_Delete", para, commandType: CommandType.StoredProcedure).FirstOrDefault();
         }
         catch (Exception ex)
         {
             Log.Error(ex);
             throw;
         }
     }
     return retVal;
 }
 public async Task<ImportError> AddFeature(ImportQueueFilter filter, FdpFeature featureToAdd)
 {
     var task = await Task.FromResult(_featureDataStore.FdpFeatureSave(featureToAdd));
     return await Task.FromResult(_importDataStore.ImportErrorGet(filter));
 }
        public async Task<ActionResult> AddMissingFeature(ImportExceptionParameters parameters)
        {
            var filter = ImportQueueFilter.FromExceptionId(parameters.ExceptionId.Value);
            var importView = await GetModelFromParameters(parameters);
            var feature = new FdpFeature()
            {
                ProgrammeId = parameters.ProgrammeId.GetValueOrDefault(),
                Gateway = parameters.Gateway,
                FeatureCode = parameters.ImportFeatureCode,
                BrandDescription = parameters.FeatureDescription,
                FeatureGroupId = parameters.FeatureGroupId
            };
            importView.CurrentException = await DataContext.Import.AddFeature(filter, feature);
            await DeactivateException(importView.CurrentException);
            await ReProcessException(importView.CurrentException);

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