/// <summary> /// Prepare paged state and province list model /// </summary> /// <param name="searchModel">State and province search model</param> /// <param name="country">Country</param> /// <returns>State and province list model</returns> public virtual StateProvinceListModel PrepareStateProvinceListModel(StateProvinceSearchModel searchModel, Country country) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (country == null) { throw new ArgumentNullException(nameof(country)); } //get comments var states = _stateProvinceService.GetStateProvincesByCountryId(country.Id, showHidden: true); //prepare list model var model = new StateProvinceListModel { //fill in model values from the entity Data = states.PaginationByRequestModel(searchModel).Select(state => state.ToModel <StateProvinceModel>()), Total = states.Count }; return(model); }
/// <summary> /// Prepare paged state and province list model /// </summary> /// <param name="searchModel">State and province search model</param> /// <param name="country">Country</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the state and province list model /// </returns> public virtual async Task <StateProvinceListModel> PrepareStateProvinceListModelAsync(StateProvinceSearchModel searchModel, Country country) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (country == null) { throw new ArgumentNullException(nameof(country)); } //get comments var states = (await _stateProvinceService.GetStateProvincesByCountryIdAsync(country.Id, showHidden: true)).ToPagedList(searchModel); //prepare list model var model = new StateProvinceListModel().PrepareToGrid(searchModel, states, () => { //fill in model values from the entity return(states.Select(state => state.ToModel <StateProvinceModel>())); }); return(model); }