Пример #1
0
        public static async Task <TrimMappingViewModel> GetModel(IDataContext context,
                                                                 TrimMappingFilter filter)
        {
            TrimMappingViewModel model = null;

            if (filter.Action == TrimMappingAction.Delete ||
                filter.Action == TrimMappingAction.Mapping ||
                filter.Action == TrimMappingAction.Copy)
            {
                model = await GetFullAndPartialViewModelForTrimMapping(context, filter);
            }
            else if (filter.Action == TrimMappingAction.Mappings ||
                     filter.Action == TrimMappingAction.CopyAll)
            {
                model = await GetFullAndPartialViewModelForTrimMappings(context, filter);
            }
            else if (filter.Action == TrimMappingAction.DPCKCodes)
            {
                model = await GetFullAndPartialViewModelForDPCKCodes(context, filter);
            }
            else
            {
                model = GetFullAndPartialViewModel(context, filter);
            }
            if (filter.Action != TrimMappingAction.NotSet)
            {
                model.IdentifierPrefix = Enum.GetName(filter.Action.GetType(), filter.Action);
            }
            return(model);
        }
Пример #2
0
        private static async Task <TrimMappingViewModel> GetFullAndPartialViewModelForTrimMapping
        (
            IDataContext context,
            TrimMappingFilter filter
        )
        {
            var baseModel = SharedModelBase.GetBaseModel(context);
            var model     = new TrimMappingViewModel()
            {
                PageIndex      = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1,
                PageSize       = filter.PageSize.HasValue ? filter.PageSize.Value : Int32.MaxValue,
                Configuration  = context.ConfigurationSettings,
                CurrentUser    = baseModel.CurrentUser,
                CurrentVersion = baseModel.CurrentVersion
            };
            var trimMapping = await context.Vehicle.GetFdpTrimMapping(filter);

            var programmeFilter = new ProgrammeFilter()
            {
                ProgrammeId = trimMapping.ProgrammeId,
                Gateway     = trimMapping.Gateway,
                //Code = model.TrimMapping.Programme.VehicleName // In order to filter the gateways specific to the programme
            };

            HydrateModelWithCommonProperties(model, context, programmeFilter);
            model.Gateways = context.Vehicle.ListGateways(programmeFilter);

            if (!(trimMapping is EmptyFdpTrimMapping))
            {
                trimMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == trimMapping.ProgrammeId);
            }
            model.TrimMapping = trimMapping;

            return(model);
        }
Пример #3
0
 private static void HydrateModelWithCommonProperties(TrimMappingViewModel 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);
 }
Пример #4
0
        private static TrimMappingViewModel GetFullAndPartialViewModel(IDataContext context,
                                                                       TrimMappingFilter filter)
        {
            var model = new TrimMappingViewModel(SharedModelBase.GetBaseModel(context))
            {
                Configuration = context.ConfigurationSettings,
            };

            HydrateModelWithCommonProperties(model, context);

            return(model);
        }
Пример #5
0
        private static async Task <TrimMappingViewModel> GetFullAndPartialViewModelForDPCKCodes
        (
            IDataContext context,
            TrimMappingFilter filter
        )
        {
            var baseModel = GetBaseModel(context);
            var model     = new TrimMappingViewModel(baseModel)
            {
                PageIndex      = filter.PageIndex ?? 1,
                PageSize       = filter.PageSize ?? 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);

            filter.IncludeAllTrim = false;
            filter.IgnoreBMC      = true;

            model.OxoTrim = await context.Vehicle.ListOxoTrim(filter);

            model.TotalPages          = model.OxoTrim.TotalPages;
            model.TotalRecords        = model.OxoTrim.TotalRecords;
            model.TotalDisplayRecords = model.OxoTrim.TotalDisplayRecords;

            foreach (var oxoTrim in model.OxoTrim.CurrentPage)
            {
                oxoTrim.Document = model.Documents
                                   .FirstOrDefault(d => d.Id == oxoTrim.DocumentId);
                oxoTrim.Programme = model.Programmes
                                    .FirstOrDefault(p => p.Id == oxoTrim.ProgrammeId);
            }

            return(model);
        }
        private static async Task<TrimMappingViewModel> GetFullAndPartialViewModelForDPCKCodes
        (
            IDataContext context,
            TrimMappingFilter filter
        )
        {
            var baseModel = GetBaseModel(context);
            var model = new TrimMappingViewModel(baseModel)
            {
                PageIndex = filter.PageIndex ?? 1,
                PageSize = filter.PageSize ?? 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);

            filter.IncludeAllTrim = false;
            filter.IgnoreBMC = true;

            model.OxoTrim = await context.Vehicle.ListOxoTrim(filter);
            model.TotalPages = model.OxoTrim.TotalPages;
            model.TotalRecords = model.OxoTrim.TotalRecords;
            model.TotalDisplayRecords = model.OxoTrim.TotalDisplayRecords;

            foreach (var oxoTrim in model.OxoTrim.CurrentPage)
            {
                oxoTrim.Document = model.Documents
                    .FirstOrDefault(d => d.Id == oxoTrim.DocumentId);
                oxoTrim.Programme = model.Programmes
                    .FirstOrDefault(p => p.Id == oxoTrim.ProgrammeId);
            }

            return model;
        }
Пример #7
0
        private static async Task <TrimMappingViewModel> GetFullAndPartialViewModelForTrimMappings
        (
            IDataContext context,
            TrimMappingFilter filter
        )
        {
            var baseModel = SharedModelBase.GetBaseModel(context);
            var model     = new TrimMappingViewModel(baseModel)
            {
                PageIndex      = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1,
                PageSize       = filter.PageSize.HasValue ? filter.PageSize.Value : Int32.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.TrimMappings = await context.Vehicle.ListFdpTrimMappings(filter);

            model.TotalPages          = model.TrimMappings.TotalPages;
            model.TotalRecords        = model.TrimMappings.TotalRecords;
            model.TotalDisplayRecords = model.TrimMappings.TotalDisplayRecords;

            foreach (var trimMapping in model.TrimMappings.CurrentPage)
            {
                trimMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == trimMapping.ProgrammeId);
            }

            return(model);
        }
Пример #8
0
 private static void HydrateModelWithCommonProperties(TrimMappingViewModel model, IDataContext context)
 {
     HydrateModelWithCommonProperties(model, context, new ProgrammeFilter());
 }
 private static void HydrateModelWithCommonProperties(TrimMappingViewModel 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 void HydrateModelWithCommonProperties(TrimMappingViewModel model, IDataContext context)
 {
     HydrateModelWithCommonProperties(model, context, new ProgrammeFilter());
 }
        private static async Task<TrimMappingViewModel> GetFullAndPartialViewModelForTrimMappings
        (
            IDataContext context,
            TrimMappingFilter filter
        )
        {
            var baseModel = SharedModelBase.GetBaseModel(context);
            var model = new TrimMappingViewModel(baseModel)
            {
                PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1,
                PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : Int32.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.TrimMappings = await context.Vehicle.ListFdpTrimMappings(filter);
            model.TotalPages = model.TrimMappings.TotalPages;
            model.TotalRecords = model.TrimMappings.TotalRecords;
            model.TotalDisplayRecords = model.TrimMappings.TotalDisplayRecords;

            foreach (var trimMapping in model.TrimMappings.CurrentPage)
            {
                trimMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == trimMapping.ProgrammeId);
            }

            return model;
        }
 private static async Task<TrimMappingViewModel> GetFullAndPartialViewModelForTrimMapping
 (
     IDataContext context,
     TrimMappingFilter filter
 )
 {
     var baseModel = SharedModelBase.GetBaseModel(context);
     var model = new TrimMappingViewModel()
     {
         PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1,
         PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : Int32.MaxValue,
         Configuration = context.ConfigurationSettings,
         CurrentUser = baseModel.CurrentUser,
         CurrentVersion = baseModel.CurrentVersion
     };
     var trimMapping = await context.Vehicle.GetFdpTrimMapping(filter);
     var programmeFilter = new ProgrammeFilter()
     {
         ProgrammeId = trimMapping.ProgrammeId,
         Gateway = trimMapping.Gateway,
         //Code = model.TrimMapping.Programme.VehicleName // In order to filter the gateways specific to the programme
     };
     HydrateModelWithCommonProperties(model, context, programmeFilter);
     model.Gateways = context.Vehicle.ListGateways(programmeFilter);
     
     if (!(trimMapping is EmptyFdpTrimMapping))
     {
         trimMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == trimMapping.ProgrammeId);
     }
     model.TrimMapping = trimMapping;
    
     return model;
 }
        private static TrimMappingViewModel GetFullAndPartialViewModel(IDataContext context,
                                                                             TrimMappingFilter filter)
        {
            var model = new TrimMappingViewModel(SharedModelBase.GetBaseModel(context))
            {
                Configuration = context.ConfigurationSettings,
            };
            HydrateModelWithCommonProperties(model, context);

            return model;
        }