private static void HydrateModelWithCommonProperties(FeatureMappingViewModel model, IDataContext context, ProgrammeFilter programmeFilter) { model.Programmes = context.Vehicle.ListProgrammes(programmeFilter); model.Gateways = model.Programmes.ListGateways(); model.CarLines = model.Programmes.ListCarLines(); model.ModelYears = model.Programmes.ListModelYears(); model.Documents = context.Vehicle.ListPublishedDocuments(programmeFilter); }
private static FeatureMappingViewModel GetFullAndPartialViewModel(IDataContext context, FeatureMappingFilter filter) { var model = new FeatureMappingViewModel(GetBaseModel(context)) { Configuration = context.ConfigurationSettings, }; HydrateModelWithCommonProperties(model, context); return model; }
private static FeatureMappingViewModel GetFullAndPartialViewModel(IDataContext context, FeatureMappingFilter filter) { var model = new FeatureMappingViewModel(GetBaseModel(context)) { Configuration = context.ConfigurationSettings, }; HydrateModelWithCommonProperties(model, context); return(model); }
private static async Task <FeatureMappingViewModel> GetFullAndPartialViewModelForFeatureMapping ( IDataContext context, FeatureMappingFilter filter ) { var baseModel = GetBaseModel(context); var model = new FeatureMappingViewModel() { PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1, PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : int.MaxValue, Configuration = context.ConfigurationSettings, CurrentUser = baseModel.CurrentUser, CurrentVersion = baseModel.CurrentVersion }; var featureMapping = await context.Vehicle.GetFdpFeatureMapping(filter); var programmeFilter = new ProgrammeFilter() { ProgrammeId = featureMapping.ProgrammeId, Gateway = featureMapping.Gateway, Code = model.FeatureMapping.Programme.VehicleName // In order to filter the gateways specific to the programme }; HydrateModelWithCommonProperties(model, context, programmeFilter); model.Gateways = context.Vehicle.ListGateways(programmeFilter); // If we are copying to another gateway, we need to remove the source gateway from the list of available gateways if (filter.Action == FeatureMappingAction.Copy) { model.Gateways = model.Gateways.Where(g => !(g.Name.Equals(featureMapping.Gateway, StringComparison.InvariantCultureIgnoreCase))); } if (!(featureMapping is EmptyFdpFeatureMapping)) { featureMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == featureMapping.ProgrammeId.GetValueOrDefault()); } model.FeatureMapping = featureMapping; return(model); }
private static async Task <FeatureMappingViewModel> GetFullAndPartialViewModelForFeatureCodes ( IDataContext context, FeatureMappingFilter filter ) { var baseModel = GetBaseModel(context); var model = new FeatureMappingViewModel(baseModel) { PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1, PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : int.MaxValue, Configuration = context.ConfigurationSettings, CurrentUser = baseModel.CurrentUser, CurrentVersion = baseModel.CurrentVersion }; var programmeFilter = new ProgrammeFilter() { ProgrammeId = filter.ProgrammeId, Gateway = filter.Gateway }; HydrateModelWithCommonProperties(model, context, programmeFilter); model.OxoFeatures = await context.Vehicle.ListOxoFeatures(filter); model.TotalPages = model.OxoFeatures.TotalPages; model.TotalRecords = model.OxoFeatures.TotalRecords; model.TotalDisplayRecords = model.OxoFeatures.TotalDisplayRecords; foreach (var oxoFeature in model.OxoFeatures.CurrentPage) { oxoFeature.Programme = model.Programmes.FirstOrDefault(p => p.Id == oxoFeature.ProgrammeId.GetValueOrDefault()); oxoFeature.Document = oxoFeature.Document = model.Documents.FirstOrDefault(d => d.Id == oxoFeature.DocumentId); } return(model); }
private static void HydrateModelWithCommonProperties(FeatureMappingViewModel model, IDataContext context) { HydrateModelWithCommonProperties(model, context, new ProgrammeFilter()); }
private static async Task<FeatureMappingViewModel> GetFullAndPartialViewModelForFeatureMapping ( IDataContext context, FeatureMappingFilter filter ) { var baseModel = GetBaseModel(context); var model = new FeatureMappingViewModel() { PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1, PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : int.MaxValue, Configuration = context.ConfigurationSettings, CurrentUser = baseModel.CurrentUser, CurrentVersion = baseModel.CurrentVersion }; var featureMapping = await context.Vehicle.GetFdpFeatureMapping(filter); var programmeFilter = new ProgrammeFilter() { ProgrammeId = featureMapping.ProgrammeId, Gateway = featureMapping.Gateway, Code = model.FeatureMapping.Programme.VehicleName // In order to filter the gateways specific to the programme }; HydrateModelWithCommonProperties(model, context, programmeFilter); model.Gateways = context.Vehicle.ListGateways(programmeFilter); // If we are copying to another gateway, we need to remove the source gateway from the list of available gateways if (filter.Action == FeatureMappingAction.Copy) { model.Gateways = model.Gateways.Where(g => !(g.Name.Equals(featureMapping.Gateway, StringComparison.InvariantCultureIgnoreCase))); } if (!(featureMapping is EmptyFdpFeatureMapping)) { featureMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == featureMapping.ProgrammeId.GetValueOrDefault()); } model.FeatureMapping = featureMapping; return model; }
private static async Task<FeatureMappingViewModel> GetFullAndPartialViewModelForFeatureCodes ( IDataContext context, FeatureMappingFilter filter ) { var baseModel = GetBaseModel(context); var model = new FeatureMappingViewModel(baseModel) { PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1, PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : int.MaxValue, Configuration = context.ConfigurationSettings, CurrentUser = baseModel.CurrentUser, CurrentVersion = baseModel.CurrentVersion }; var programmeFilter = new ProgrammeFilter() { ProgrammeId = filter.ProgrammeId, Gateway = filter.Gateway }; HydrateModelWithCommonProperties(model, context, programmeFilter); model.OxoFeatures = await context.Vehicle.ListOxoFeatures(filter); model.TotalPages = model.OxoFeatures.TotalPages; model.TotalRecords = model.OxoFeatures.TotalRecords; model.TotalDisplayRecords = model.OxoFeatures.TotalDisplayRecords; foreach (var oxoFeature in model.OxoFeatures.CurrentPage) { oxoFeature.Programme = model.Programmes.FirstOrDefault(p => p.Id == oxoFeature.ProgrammeId.GetValueOrDefault()); oxoFeature.Document = oxoFeature.Document = model.Documents.FirstOrDefault(d => d.Id == oxoFeature.DocumentId); } return model; }