コード例 #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> 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;
        }
コード例 #3
0
        private static async Task<ImportViewModel> GetFullAndPartialViewModelForException(IDataContext context,
                                                                                          ImportQueueFilter filter)
        {
            var model = new ImportViewModel(GetBaseModel(context))
            {
                PageIndex = filter.PageIndex ?? 1,
                PageSize = filter.PageSize ?? int.MaxValue,
                Configuration = context.ConfigurationSettings,
                CurrentException = await context.Import.GetException(filter)
            };

            var programmeFilter = new ProgrammeFilter(model.CurrentException.ProgrammeId) { DocumentId = model.CurrentException.DocumentId };
            var featureFilter = new FeatureFilter { ProgrammeId = model.CurrentException.ProgrammeId, DocumentId = model.CurrentException.DocumentId };
            
            model.Programme = context.Vehicle.GetProgramme(programmeFilter);
            programmeFilter.VehicleId = model.Programme.VehicleId;

            model.Gateway = model.CurrentException.Gateway;
            model.AvailableDocuments = context.Vehicle.ListPublishedDocuments(programmeFilter);
            model.AvailableEngines = context.Vehicle.ListEngines(programmeFilter);
            model.AvailableTransmissions = context.Vehicle.ListTransmissions(programmeFilter);
            model.AvailableBodies = context.Vehicle.ListBodies(programmeFilter);
            model.AvailableSpecialFeatures = await context.TakeRate.ListSpecialFeatures(programmeFilter);
            model.AvailableMarkets = await context.Market.ListAvailableMarkets();
            model.AvailableFeatures = await context.Vehicle.ListFeatures(featureFilter);
            model.AvailableFeatureGroups = context.Vehicle.ListFeatureGroups(programmeFilter);
            model.AvailableTrimLevels = context.Vehicle.ListTrimLevels(programmeFilter);

            var derivativeFilter = new DerivativeFilter
            {
                CarLine = model.Programme.VehicleName,
                ModelYear = model.Programme.ModelYear,
                Gateway = model.Gateway,
                ProgrammeId = model.CurrentException.ProgrammeId,
            };

            model.AvailableDerivatives = context.Vehicle.ListDerivatives(derivativeFilter);
            model.AvailableImportDerivatives = await ListImportDerivatives(model.CurrentException.ImportQueueId, context);
            model.AvailableImportTrimLevels = await ListImportTrimLevels(model.CurrentException.ImportQueueId, context);
            model.AvailableImportFeatures = await ListImportFeatures(model.CurrentException.ImportQueueId, context);

            derivativeFilter.Bmc = model.CurrentException.ImportDerivativeCode;
           
            var trimFilter = new TrimMappingFilter
            {
                CarLine = model.Programme.VehicleName,
                ModelYear = model.Programme.ModelYear,
                Gateway = model.Gateway,
                DocumentId = model.CurrentException is EmptyOxoDocument ? (int?) null : model.CurrentException.DocumentId,
                IncludeAllTrim = false
            };
            model.AvailableTrim = (await context.Vehicle.ListOxoTrim(trimFilter)).CurrentPage;
            model.Document = model.AvailableDocuments.FirstOrDefault(d => d.Id == model.CurrentException.DocumentId);

            return model;
        }
コード例 #4
0
 public async Task<PagedResults<OxoTrim>> ListOxoTrim(TrimMappingFilter filter)
 {
     filter.IncludeAllTrim = true;
     filter.OxoTrimOnly = true;
     filter.PageSize = 0;
     return await Task.FromResult(_trimDataStore.FdpOxoTrimGetMany(filter));
 }
コード例 #5
0
 public async Task<PagedResults<FdpTrimMapping>> ListFdpTrimMappings(TrimMappingFilter filter)
 {
     return await Task.FromResult(_trimDataStore.FdpTrimMappingGetMany(filter));
 }
コード例 #6
0
 public async Task<FdpTrimMapping> GetFdpTrimMapping(TrimMappingFilter filter)
 {
     return await Task.FromResult(_trimDataStore.FdpTrimMappingGet(filter));
 }
コード例 #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 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;
 }
コード例 #9
0
        private static TrimMappingViewModel GetFullAndPartialViewModel(IDataContext context,
                                                                             TrimMappingFilter filter)
        {
            var model = new TrimMappingViewModel(SharedModelBase.GetBaseModel(context))
            {
                Configuration = context.ConfigurationSettings,
            };
            HydrateModelWithCommonProperties(model, context);

            return model;
        }
コード例 #10
0
 public PagedResults<OxoTrim> FdpOxoTrimGetMany(TrimMappingFilter filter)
 {
     var results = FdpTrimMappingGetMany(filter);
     var page = results.CurrentPage.Select(result => new OxoTrim(result)).ToList();
     return new PagedResults<OxoTrim>
     {
         PageIndex = results.PageIndex,
         PageSize = results.PageSize,
         TotalDisplayRecords = results.TotalDisplayRecords,
         TotalFail = results.TotalFail,
         TotalRecords = results.TotalRecords,
         TotalSuccess = results.TotalSuccess,
         CurrentPage = page
     };
 }
コード例 #11
0
        public FdpTrimMapping FdpTrimMappingGet(TrimMappingFilter filter)
        {
            FdpTrimMapping retVal = new EmptyFdpTrimMapping();
            using (IDbConnection conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@FdpTrimMappingId", filter.TrimMappingId.GetValueOrDefault(), DbType.Int32);

                    var results = conn.Query<FdpTrimMapping>("Fdp_TrimMapping_Get", para, commandType: CommandType.StoredProcedure);
                    if (results.Any())
                    {
                        retVal = results.First();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }
            return retVal;
        }