/// <summary>
        /// Prepare paged measure weight list model
        /// </summary>
        /// <param name="searchModel">Measure weight search model</param>
        /// <returns>Measure weight list model</returns>
        public virtual MeasureWeightListModel PrepareMeasureWeightListModel(MeasureWeightSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get weights
            var weights = _measureService.GetAllMeasureWeights();

            //prepare list model
            var model = new MeasureWeightListModel
            {
                Data = weights.PaginationByRequestModel(searchModel).Select(weight =>
                {
                    //fill in model values from the entity
                    var weightModel = weight.ToModel <MeasureWeightModel>();

                    //fill in additional values (not existing in the entity)
                    weightModel.IsPrimaryWeight = weight.Id == _measureSettings.BaseWeightId;

                    return(weightModel);
                }),
                Total = weights.Count
            };

            return(model);
        }
        /// <summary>
        /// Prepare paged measure weight list model
        /// </summary>
        /// <param name="searchModel">Measure weight search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the measure weight list model
        /// </returns>
        public virtual async Task <MeasureWeightListModel> PrepareMeasureWeightListModelAsync(MeasureWeightSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get weights
            var weights = (await _measureService.GetAllMeasureWeightsAsync()).ToPagedList(searchModel);

            //prepare list model
            var model = new MeasureWeightListModel().PrepareToGrid(searchModel, weights, () =>
            {
                return(weights.Select(weight =>
                {
                    //fill in model values from the entity
                    var weightModel = weight.ToModel <MeasureWeightModel>();

                    //fill in additional values (not existing in the entity)
                    weightModel.IsPrimaryWeight = weight.Id == _measureSettings.BaseWeightId;

                    return weightModel;
                }));
            });

            return(model);
        }