public virtual IActionResult List(SpecificationAttributeSearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes)) { return(AccessDeniedKendoGridJson()); } //prepare model var model = _specificationAttributeModelFactory.PrepareSpecificationAttributeListModel(searchModel); return(Json(model)); }
public virtual async Task <IActionResult> SpecificationAttributeList(SpecificationAttributeSearchModel searchModel) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageAttributes)) { return(await AccessDeniedDataTablesJson()); } SpecificationAttributeGroup group = null; if (searchModel.SpecificationAttributeGroupId > 0) { group = await _specificationAttributeService.GetSpecificationAttributeGroupByIdAsync(searchModel.SpecificationAttributeGroupId) ?? throw new ArgumentException("No specification attribute group found with the specified id"); } var model = await _specificationAttributeModelFactory.PrepareSpecificationAttributeListModelAsync(searchModel, group); return(Json(model)); }
/// <summary> /// Prepare paged specification attribute list model /// </summary> /// <param name="searchModel">Specification attribute search model</param> /// <returns>Specification attribute list model</returns> public virtual SpecificationAttributeListModel PrepareSpecificationAttributeListModel(SpecificationAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get specification attributes var specificationAttributes = _specificationAttributeService .GetSpecificationAttributes(searchModel.Page - 1, searchModel.PageSize); //prepare list model var model = new SpecificationAttributeListModel().PrepareToGrid(searchModel, specificationAttributes, () => { //fill in model values from the entity return(specificationAttributes.Select(attribute => attribute.ToModel <SpecificationAttributeModel>())); }); return(model); }
/// <summary> /// Prepare specification attribute search model /// </summary> /// <param name="searchModel">Specification attribute search model</param> /// <returns>Specification attribute search model</returns> public virtual SpecificationAttributeSearchModel PrepareSpecificationAttributeSearchModel(SpecificationAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
/// <summary> /// Prepare paged specification attribute list model /// </summary> /// <param name="searchModel">Specification attribute search model</param> /// <param name="group">Specification attribute group</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the specification attribute list model /// </returns> public virtual async Task <SpecificationAttributeListModel> PrepareSpecificationAttributeListModelAsync(SpecificationAttributeSearchModel searchModel, SpecificationAttributeGroup group) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get specification attributes var specificationAttributes = (await _specificationAttributeService.GetSpecificationAttributesByGroupIdAsync(group?.Id)).ToPagedList(searchModel); //prepare list model var model = new SpecificationAttributeListModel().PrepareToGrid(searchModel, specificationAttributes, () => { //fill in model values from the entity return(specificationAttributes.Select(attribute => attribute.ToModel <SpecificationAttributeModel>())); }); return(model); }
/// <summary> /// Prepare paged specification attribute list model /// </summary> /// <param name="searchModel">Specification attribute search model</param> /// <returns>Specification attribute list model</returns> public virtual SpecificationAttributeListModel PrepareSpecificationAttributeListModel(SpecificationAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get specification attributes var specificationAttributes = _specificationAttributeService .GetSpecificationAttributes(searchModel.Page - 1, searchModel.PageSize); //prepare list model var model = new SpecificationAttributeListModel { //fill in model values from the entity Data = specificationAttributes.Select(attribute => attribute.ToModel()), Total = specificationAttributes.TotalCount }; return(model); }