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)); }
public async Task <ActionResult> UpdateFeatureCode(FeatureMappingParameters parameters) { ValidateFeatureMappingParameters(parameters, FeatureMappingParametersValidator.UpdateFeatureCode); await DataContext.Vehicle.UpdateFeatureCode(OxoFeature.FromParameters(parameters)); return(JsonGetSuccess()); }
public static FeatureMappingFilter FromFeatureMappingParameters(FeatureMappingParameters parameters) { return(new FeatureMappingFilter() { FeatureMappingId = parameters.FeatureMappingId, Action = parameters.Action }); }
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)); }
public static FdpFeatureMapping FromParameters(FeatureMappingParameters parameters) { return(new FdpFeatureMapping() { FdpFeatureMappingId = parameters.FeatureMappingId, ProgrammeId = parameters.ProgrammeId, Gateway = parameters.Gateway }); }
public async Task <ActionResult> FeatureCodePage(FeatureMappingParameters parameters) { var filter = new FeatureMappingFilter() { PageIndex = PageIndex, PageSize = PageSize }; return(View(await FeatureMappingViewModel.GetModel(DataContext, filter))); }
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); } }
public new static OxoFeature FromParameters(FeatureMappingParameters parameters) { return(new OxoFeature { FeatureId = parameters.FeatureId, FeaturePackId = parameters.FeaturePackId, DocumentId = parameters.DocumentId, FeatureCode = parameters.FeatureCode }); }
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())); }
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)); }
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)); }
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()); }
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()); }
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()); }
protected override bool IsValid(PropertyValidatorContext context) { Parameters = context.ParentContext.InstanceToValidate as FeatureMappingParameters; return(Parameters.FeatureId.HasValue || Parameters.FeaturePackId.HasValue); }
private async Task <FeatureMappingViewModel> GetModelFromParameters(FeatureMappingParameters parameters) { return(await FeatureMappingViewModel.GetModel(DataContext, FeatureMappingFilter.FromFeatureMappingParameters(parameters))); }