Exemple #1
0
        /// <summary>
        /// Prepare paged address attribute list model
        /// </summary>
        /// <param name="searchModel">Address attribute search model</param>
        /// <returns>Address attribute list model</returns>
        public virtual AddressAttributeListModel PrepareAddressAttributeListModel(AddressAttributeSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get address attributes
            var addressAttributes = _addressAttributeService.GetAllAddressAttributes();

            //prepare grid model
            var model = new AddressAttributeListModel
            {
                Data = addressAttributes.PaginationByRequestModel(searchModel).Select(attribute =>
                {
                    //fill in model values from the entity
                    var attributeModel = attribute.ToModel <AddressAttributeModel>();

                    return(attributeModel);
                }),
                Total = addressAttributes.Count
            };

            return(model);
        }
        /// <summary>
        /// Prepare paged address attribute list model
        /// </summary>
        /// <param name="searchModel">Address attribute search model</param>
        /// <returns>Address attribute list model</returns>
        public virtual AddressAttributeListModel PrepareAddressAttributeListModel(AddressAttributeSearchModel searchModel)
        {
            if (searchModel == null)
                throw new ArgumentNullException(nameof(searchModel));

            //get address attributes
            var addressAttributes = _addressAttributeService.GetAllAddressAttributes();

            //prepare grid model
            var model = new AddressAttributeListModel
            {
                Data = addressAttributes.PaginationByRequestModel(searchModel).Select(attribute =>
                {
                    //fill in model values from the entity
                    var attributeModel = attribute.ToModel<AddressAttributeModel>();

                    //fill in additional values (not existing in the entity)
                    attributeModel.AttributeControlTypeName = _localizationService.GetLocalizedEnum(attribute.AttributeControlType);

                    return attributeModel;
                }),
                Total = addressAttributes.Count
            };

            return model;
        }
Exemple #3
0
        /// <summary>
        /// Prepare paged address attribute list model
        /// </summary>
        /// <param name="searchModel">Address attribute search model</param>
        /// <returns>Address attribute list model</returns>
        public virtual AddressAttributeListModel PrepareAddressAttributeListModel(AddressAttributeSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get address attributes
            var addressAttributes = _addressAttributeService.GetAllAddressAttributes().ToPagedList(searchModel);

            //prepare grid model
            var model = new AddressAttributeListModel().PrepareToGrid(searchModel, addressAttributes, () =>
            {
                return(addressAttributes.Select(attribute =>
                {
                    //fill in model values from the entity
                    var attributeModel = attribute.ToModel <AddressAttributeModel>();

                    //fill in additional values (not existing in the entity)
                    attributeModel.AttributeControlTypeName =
                        _localizationService.GetLocalizedEnum(attribute.AttributeControlType);

                    return attributeModel;
                }));
            });

            return(model);
        }