/// <summary> /// Prepare paged checkout attribute list model /// </summary> /// <param name="searchModel">Checkout attribute search model</param> /// <returns>Checkout attribute list model</returns> public virtual CheckoutAttributeListModel PrepareCheckoutAttributeListModel(CheckoutAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get checkout attributes var checkoutAttributes = _checkoutAttributeService.GetAllCheckoutAttributes(); //prepare list model var model = new CheckoutAttributeListModel { Data = checkoutAttributes.PaginationByRequestModel(searchModel).Select(attribute => { //fill in model values from the entity var attributeModel = attribute.ToModel <CheckoutAttributeModel>(); //fill in additional values (not existing in the entity) attributeModel.AttributeControlTypeName = _localizationService.GetLocalizedEnum(attribute.AttributeControlType); return(attributeModel); }), Total = checkoutAttributes.Count }; return(model); }
/// <summary> /// Prepare paged checkout attribute list model /// </summary> /// <param name="searchModel">Checkout attribute search model</param> /// <returns>Checkout attribute list model</returns> public virtual CheckoutAttributeListModel PrepareCheckoutAttributeListModel(CheckoutAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get checkout attributes var checkoutAttributes = _checkoutAttributeService.GetAllCheckoutAttributes().ToPagedList(searchModel); //prepare list model var model = new CheckoutAttributeListModel().PrepareToGrid(searchModel, checkoutAttributes, () => { return(checkoutAttributes.Select(attribute => { //fill in model values from the entity var attributeModel = attribute.ToModel <CheckoutAttributeModel>(); //fill in additional values (not existing in the entity) attributeModel.AttributeControlTypeName = _localizationService.GetLocalizedEnum(attribute.AttributeControlType); return attributeModel; })); }); return(model); }
public virtual IActionResult List(CheckoutAttributeSearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes)) return AccessDeniedKendoGridJson(); //prepare model var model = _checkoutAttributeModelFactory.PrepareCheckoutAttributeListModel(searchModel); return Json(model); }
public virtual async Task <IActionResult> List(CheckoutAttributeSearchModel searchModel) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageAttributes)) { return(await AccessDeniedDataTablesJson()); } //prepare model var model = await _checkoutAttributeModelFactory.PrepareCheckoutAttributeListModelAsync(searchModel); return(Json(model)); }
/// <summary> /// Prepare checkout attribute search model /// </summary> /// <param name="searchModel">Checkout attribute search model</param> /// <returns>Checkout attribute search model</returns> public virtual CheckoutAttributeSearchModel PrepareCheckoutAttributeSearchModel(CheckoutAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
/// <summary> /// Prepare checkout attribute search model /// </summary> /// <param name="searchModel">Checkout attribute search model</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the checkout attribute search model /// </returns> public virtual Task <CheckoutAttributeSearchModel> PrepareCheckoutAttributeSearchModelAsync(CheckoutAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare page parameters searchModel.SetGridPageSize(); return(Task.FromResult(searchModel)); }