コード例 #1
0
        public async Task <ActionResult> ListFeatureCodes(FeatureMappingParameters parameters)
        {
            ValidateFeatureMappingParameters(parameters, FeatureMappingParametersValidator.NoValidation);

            var filter = new FeatureMappingFilter()
            {
                FilterMessage = parameters.FilterMessage,
                CarLine       = parameters.CarLine,
                ModelYear     = parameters.ModelYear,
                Gateway       = parameters.Gateway,
                Action        = FeatureMappingAction.FeatureCodes,
                DocumentId    = parameters.DocumentId
            };

            filter.InitialiseFromJson(parameters);

            var results = await FeatureMappingViewModel.GetModel(DataContext, filter);

            var jQueryResult = new JQueryDataTableResultModel(results);

            foreach (var result in results.OxoFeatures.CurrentPage)
            {
                try
                {
                    jQueryResult.aaData.Add(result.ToJQueryDataTableResult());
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
            }
            return(Json(jQueryResult));
        }
コード例 #2
0
        public async Task <ActionResult> UpdateFeatureCode(FeatureMappingParameters parameters)
        {
            ValidateFeatureMappingParameters(parameters, FeatureMappingParametersValidator.UpdateFeatureCode);

            await DataContext.Vehicle.UpdateFeatureCode(OxoFeature.FromParameters(parameters));

            return(JsonGetSuccess());
        }
コード例 #3
0
 public static FeatureMappingFilter FromFeatureMappingParameters(FeatureMappingParameters parameters)
 {
     return(new FeatureMappingFilter()
     {
         FeatureMappingId = parameters.FeatureMappingId,
         Action = parameters.Action
     });
 }
コード例 #4
0
        public async Task <ActionResult> ModalContent(FeatureMappingParameters parameters)
        {
            ValidateFeatureMappingParameters(parameters, FeatureMappingParametersValidator.Action);

            var filter = FeatureMappingFilter.FromFeatureMappingParameters(parameters);
            var derivativeMappingView = await FeatureMappingViewModel.GetModel(DataContext, filter);

            return(PartialView(GetContentPartialViewName(parameters.Action), derivativeMappingView));
        }
コード例 #5
0
 public static FdpFeatureMapping FromParameters(FeatureMappingParameters parameters)
 {
     return(new FdpFeatureMapping()
     {
         FdpFeatureMappingId = parameters.FeatureMappingId,
         ProgrammeId = parameters.ProgrammeId,
         Gateway = parameters.Gateway
     });
 }
コード例 #6
0
        public async Task <ActionResult> FeatureCodePage(FeatureMappingParameters parameters)
        {
            var filter = new FeatureMappingFilter()
            {
                PageIndex = PageIndex,
                PageSize  = PageSize
            };

            return(View(await FeatureMappingViewModel.GetModel(DataContext, filter)));
        }
コード例 #7
0
        private void ValidateFeatureMappingParameters(FeatureMappingParameters parameters, string ruleSetName)
        {
            var validator = new FeatureMappingParametersValidator(DataContext);
            var result    = validator.Validate(parameters, ruleSet: ruleSetName);

            if (!result.IsValid)
            {
                throw new ValidationException(result.Errors);
            }
        }
コード例 #8
0
 public new static OxoFeature FromParameters(FeatureMappingParameters parameters)
 {
     return(new OxoFeature
     {
         FeatureId = parameters.FeatureId,
         FeaturePackId = parameters.FeaturePackId,
         DocumentId = parameters.DocumentId,
         FeatureCode = parameters.FeatureCode
     });
 }
コード例 #9
0
        public ActionResult ModalAction(FeatureMappingParameters parameters)
        {
            ValidateFeatureMappingParameters(parameters, FeatureMappingParametersValidator.FeatureIdentifierWithAction);
            ValidateFeatureMappingParameters(parameters, Enum.GetName(parameters.Action.GetType(), parameters.Action));

            if (parameters.Action == FeatureMappingAction.CopyAll || parameters.Action == FeatureMappingAction.Copy)
            {
                TempData["CopyToGateways"] = parameters.CopyToGateways;
            }

            return(RedirectToAction(Enum.GetName(parameters.Action.GetType(), parameters.Action), parameters.GetActionSpecificParameters()));
        }
コード例 #10
0
        public async Task <ActionResult> ContextMenu(FeatureMappingParameters parameters)
        {
            ValidateFeatureMappingParameters(parameters, FeatureMappingParametersValidator.FeatureMappingIdentifier);

            var filter = FeatureMappingFilter.FromFeatureMappingParameters(parameters);

            filter.Action = FeatureMappingAction.Mapping;

            var derivativeMappingView = await FeatureMappingViewModel.GetModel(DataContext, filter);

            return(PartialView("_ContextMenu", derivativeMappingView));
        }
コード例 #11
0
        protected override bool IsValid(PropertyValidatorContext context)
        {
            Parameters = context.ParentContext.InstanceToValidate as FeatureMappingParameters;

            var filter = FeatureMappingFilter.FromFeatureMappingParameters(Parameters);

            filter.PageSize = int.MaxValue;

            var oxoFeatures =
                _context.Vehicle.ListOxoFeatures(filter).Result;

            return
                (!oxoFeatures.CurrentPage.Any(IsExistingFeatureCode));
        }
コード例 #12
0
        public async Task <ActionResult> CopyAll(FeatureMappingParameters parameters)
        {
            var derivativeMappingView = await GetModelFromParameters(parameters);

            if (derivativeMappingView.FeatureMapping is EmptyFdpFeatureMapping)
            {
                return(JsonGetFailure("FeatureMapping does not exist"));
            }

            var results = await DataContext.Vehicle.CopyFdpFeatureMappingsToDocument(parameters.DocumentId.GetValueOrDefault(), parameters.TargetDocumentId.GetValueOrDefault());

            if (results == null || !results.Any())
            {
                return(JsonGetFailure(string.Format("FeatureMappings could not be copied", derivativeMappingView.FeatureMapping.ImportFeatureCode)));
            }

            return(JsonGetSuccess());
        }
コード例 #13
0
        public async Task <ActionResult> Delete(FeatureMappingParameters parameters)
        {
            var derivativeMappingView = await GetModelFromParameters(parameters);

            if (derivativeMappingView.FeatureMapping is EmptyFdpFeatureMapping)
            {
                return(JsonGetFailure("FeatureMapping does not exist"));
            }

            derivativeMappingView.FeatureMapping = await DataContext.Vehicle.DeleteFdpFeatureMapping(FdpFeatureMapping.FromParameters(parameters));

            if (derivativeMappingView.FeatureMapping is EmptyFdpFeatureMapping)
            {
                return(JsonGetFailure(string.Format("FeatureMapping '{0}' could not be deleted", derivativeMappingView.FeatureMapping.ImportFeatureCode)));
            }

            return(JsonGetSuccess());
        }
コード例 #14
0
        public async Task <ActionResult> Copy(FeatureMappingParameters parameters)
        {
            parameters.CopyToGateways = (IEnumerable <string>)TempData["CopyToGateways"];
            var derivativeMappingView = await GetModelFromParameters(parameters);

            if (derivativeMappingView.FeatureMapping is EmptyFdpFeatureMapping)
            {
                return(JsonGetFailure("FeatureMapping does not exist"));
            }

            derivativeMappingView.FeatureMapping = await DataContext.Vehicle.CopyFdpFeatureMappingToDocument(FdpFeatureMapping.FromParameters(parameters), parameters.TargetDocumentId.GetValueOrDefault());

            if (derivativeMappingView.FeatureMapping is EmptyFdpFeatureMapping)
            {
                return(JsonGetFailure(string.Format("FeatureMapping '{0}' could not be copied", derivativeMappingView.FeatureMapping.ImportFeatureCode)));
            }

            return(JsonGetSuccess());
        }
コード例 #15
0
        protected override bool IsValid(PropertyValidatorContext context)
        {
            Parameters = context.ParentContext.InstanceToValidate as FeatureMappingParameters;

            return(Parameters.FeatureId.HasValue || Parameters.FeaturePackId.HasValue);
        }
コード例 #16
0
 private async Task <FeatureMappingViewModel> GetModelFromParameters(FeatureMappingParameters parameters)
 {
     return(await FeatureMappingViewModel.GetModel(DataContext, FeatureMappingFilter.FromFeatureMappingParameters(parameters)));
 }