public async Task <ActionResult> ListTrims(TrimParameters parameters) { ValidateTrimParameters(parameters, TrimParametersValidator.NoValidation); var filter = new TrimFilter() { FilterMessage = parameters.FilterMessage, CarLine = parameters.CarLine, ModelYear = parameters.ModelYear, Gateway = parameters.Gateway, Action = TrimAction.TrimLevels }; filter.InitialiseFromJson(parameters); var results = await TrimViewModel.GetModel(DataContext, filter); var jQueryResult = new JQueryDataTableResultModel(results); foreach (var result in results.Trims.CurrentPage) { jQueryResult.aaData.Add(result.ToJQueryDataTableResult()); } return(Json(jQueryResult)); }
public ActionResult ModalAction(TrimParameters parameters) { ValidateTrimParameters(parameters, TrimParametersValidator.TrimIdentifierWithAction); ValidateTrimParameters(parameters, Enum.GetName(parameters.Action.GetType(), parameters.Action)); return(RedirectToAction(Enum.GetName(parameters.Action.GetType(), parameters.Action), parameters.GetActionSpecificParameters())); }
public static TrimFilter FromParameters(TrimParameters parameters) { return(new TrimFilter { TrimId = parameters.TrimId, Action = parameters.Action }); }
public async Task <ActionResult> ModalContent(TrimParameters parameters) { ValidateTrimParameters(parameters, TrimParametersValidator.Action); var filter = TrimMappingFilter.FromParameters(parameters); var derivativeView = await GetModelFromParameters(parameters); return(PartialView(GetContentPartialViewName(parameters.Action), derivativeView)); }
public async Task <ActionResult> TrimPage(TrimParameters parameters) { var filter = new TrimFilter() { PageIndex = PageIndex, PageSize = PageSize }; return(View(await TrimViewModel.GetModel(DataContext, filter))); }
private void ValidateTrimParameters(TrimParameters parameters, string ruleSetName) { var validator = new TrimParametersValidator(); var result = validator.Validate(parameters, ruleSet: ruleSetName); if (!result.IsValid) { throw new ValidationException(result.Errors); } }
public async Task <ActionResult> ContextMenu(TrimParameters parameters) { ValidateTrimParameters(parameters, TrimParametersValidator.TrimIdentifier); var filter = TrimFilter.FromParameters(parameters); filter.Action = TrimAction.Trim; var derivativeView = await TrimViewModel.GetModel(DataContext, filter); return(PartialView("_ContextMenu", derivativeView)); }
public async Task <ActionResult> Delete(TrimParameters parameters) { var derivativeView = await GetModelFromParameters(parameters); if (derivativeView.Trim is EmptyFdpTrim) { return(JsonGetFailure(string.Format("Trim does not exist", parameters.TrimId))); } derivativeView.Trim = await DataContext.Vehicle.DeleteFdpTrim(FdpTrim.FromParameters(parameters)); if (derivativeView.Trim is EmptyFdpTrim) { return(JsonGetFailure(string.Format("Trim '{0}' could not be deleted", derivativeView.Trim.Name))); } return(JsonGetSuccess()); }
private async Task <TrimViewModel> GetModelFromParameters(TrimParameters parameters) { return(await TrimViewModel.GetModel(DataContext, TrimMappingFilter.FromParameters(parameters))); }