Exemple #1
0
        /// <summary>
        /// Prepare paged shipping method list model
        /// </summary>
        /// <param name="searchModel">Shipping method search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the shipping method list model
        /// </returns>
        public virtual async Task <ShippingMethodListModel> PrepareShippingMethodListModelAsync(ShippingMethodSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get shipping methods
            var shippingMethods = (await _shippingService.GetAllShippingMethodsAsync()).ToPagedList(searchModel);

            //prepare grid model
            var model = new ShippingMethodListModel().PrepareToGrid(searchModel, shippingMethods, () =>
            {
                return(shippingMethods.Select(method => method.ToModel <ShippingMethodModel>()));
            });

            return(model);
        }
Exemple #2
0
        /// <summary>
        /// Prepare paged shipping method list model
        /// </summary>
        /// <param name="searchModel">Shipping method search model</param>
        /// <returns>Shipping method list model</returns>
        public virtual ShippingMethodListModel PrepareShippingMethodListModel(ShippingMethodSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get shipping methods
            var shippingMethods = _shippingService.GetAllShippingMethods();

            //prepare grid model
            var model = new ShippingMethodListModel
            {
                //fill in model values from the entity
                Data  = shippingMethods.PaginationByRequestModel(searchModel).Select(method => method.ToModel()),
                Total = shippingMethods.Count
            };

            return(model);
        }