コード例 #1
0
 private static async Task<MarketMappingViewModel> GetFullAndPartialViewModelForMarketMapping
 (
     IDataContext context,
     MarketMappingFilter filter
 )
 {
     var baseModel = SharedModelBase.GetBaseModel(context);
     var model = new MarketMappingViewModel()
     {
         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 marketMapping = await context.Market.GetFdpMarketMapping(filter);
     var programmeFilter = new ProgrammeFilter()
     {
         ProgrammeId = marketMapping.ProgrammeId,
         Gateway = marketMapping.Gateway,
         Code = model.MarketMapping.Programme.VehicleName // In order to filter the gateways specific to the programme
     };
     HydrateModelWithCommonProperties(model, context, programmeFilter);
     model.Gateways = context.Vehicle.ListGateways(programmeFilter);
     
     if (!(marketMapping is EmptyFdpMarketMapping))
     {
         marketMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == marketMapping.ProgrammeId.GetValueOrDefault());
     }
     model.MarketMapping = marketMapping;
    
     return model;
 }
コード例 #2
0
        public static async Task<MarketMappingViewModel> GetModel(IDataContext context,
                                                                      MarketMappingFilter filter)
        {
            MarketMappingViewModel model = null;

            if (filter.Action == MarketMappingAction.Delete 
                || filter.Action == MarketMappingAction.Mapping
                || filter.Action == MarketMappingAction.Copy)
            {
                model = await GetFullAndPartialViewModelForMarketMapping(context, filter);
            }
            else if (filter.Action == MarketMappingAction.Mappings ||
                filter.Action == MarketMappingAction.CopyAll)
            {
                model = await GetFullAndPartialViewModelForMarketMappings(context, filter);
            }
            else
            {
                model = GetFullAndPartialViewModel(context, filter);
            }
            if (filter.Action != MarketMappingAction.NotSet)
            {
                model.IdentifierPrefix = Enum.GetName(filter.Action.GetType(), filter.Action);
            }
            return model;
        }
コード例 #3
0
        private static MarketMappingViewModel GetFullAndPartialViewModel(IDataContext context,
                                                                             MarketMappingFilter filter)
        {
            var model = new MarketMappingViewModel(SharedModelBase.GetBaseModel(context))
            {
                Configuration = context.ConfigurationSettings,
            };
            HydrateModelWithCommonProperties(model, context);

            return model;
        }
コード例 #4
0
 public async Task<PagedResults<FdpMarketMapping>> ListFdpMarketMappings(MarketMappingFilter filter)
 {
     return await Task.FromResult<PagedResults<FdpMarketMapping>>(_marketDataStore.FdpMarketMappingGetMany(filter));
 }
コード例 #5
0
 public async Task<FdpMarketMapping> GetFdpMarketMapping(MarketMappingFilter filter)
 {
     return await Task.FromResult<FdpMarketMapping>(_marketDataStore.FdpMarketMappingGet(filter));
 }
コード例 #6
0
        private static async Task<MarketMappingViewModel> GetFullAndPartialViewModelForMarketMappings
        (
            IDataContext context,
            MarketMappingFilter filter
        )
        {
            var baseModel = SharedModelBase.GetBaseModel(context);
            var model = new MarketMappingViewModel(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.MarketMappings = await context.Market.ListFdpMarketMappings(filter);
            model.TotalPages = model.MarketMappings.TotalPages;
            model.TotalRecords = model.MarketMappings.TotalRecords;
            model.TotalDisplayRecords = model.MarketMappings.TotalDisplayRecords;

            foreach (var marketMapping in model.MarketMappings.CurrentPage)
            {
                marketMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == marketMapping.ProgrammeId.GetValueOrDefault());
            }

            return model;
        }
コード例 #7
0
        public FdpMarketMapping FdpMarketMappingGet(MarketMappingFilter filter)
        {
            FdpMarketMapping retVal = new EmptyFdpMarketMapping();
            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@FdpMarketMappingId", filter.MarketMappingId.GetValueOrDefault(), DbType.Int32);

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