public TakeRateDataItem()
 {
     Notes = Enumerable.Empty<TakeRateDataItemNote>();
     History = Enumerable.Empty<TakeRateDataItemAudit>();
     Model = new EmptyFdpModel();
     Feature = new EmptyFdpFeature();
     HasUncommittedChanges = false;
 }
 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 FdpFeatureGet(FeatureFilter filter)
 {
     FdpFeature retVal = new EmptyFdpFeature();
     using (IDbConnection conn = DbHelper.GetDBConnection())
     {
         try
         {
             var para = new DynamicParameters();
             para.Add("@FdpFeatureId", filter.FeatureId.GetValueOrDefault(), DbType.Int32);
             retVal = conn.Query<FdpFeature>("dbo.Fdp_Feature_Get", 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;
 }
        private static async Task<FdpFeature> HydrateCurrentFeature(IDataContext context, TakeRateViewModel takeRateModel)
        {
            FdpFeature feature = new EmptyFdpFeature();

            if (takeRateModel.CurrentTakeRateDataItem.FeatureId.HasValue)
            {
                feature = takeRateModel.Document.Vehicle.AvailableFeatures.First(f => f.Id == takeRateModel.CurrentTakeRateDataItem.FeatureId.Value);
            }
            else if (takeRateModel.CurrentTakeRateDataItem.FdpFeatureId.HasValue)
            {
                feature = takeRateModel.Document.Vehicle.AvailableFeatures.First(f => f.FdpFeatureId == takeRateModel.CurrentTakeRateDataItem.FdpFeatureId.Value);
            }
            takeRateModel.CurrentTakeRateDataItem.Feature = feature;

            return await Task.FromResult(feature);
        }
 private void InitialiseMembers()
 {
     Feature = new EmptyFdpFeature();
     IdentifierPrefix = "Page";
     Programmes = Enumerable.Empty<Programme>();
     Gateways = Enumerable.Empty<Gateway>();
     CarLines = Enumerable.Empty<CarLine>();
     ModelYears = Enumerable.Empty<ModelYear>();
     CurrentAction = FeatureAction.NotSet;
 }