/// <summary>
        /// Prepare paged return request reason list model
        /// </summary>
        /// <param name="searchModel">Return request reason search model</param>
        /// <returns>Return request reason list model</returns>
        public virtual async Task <ReturnRequestReasonListModel> PrepareReturnRequestReasonListModelAsync(ReturnRequestReasonSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get return request reasons
            var reasons = (await _returnRequestService.GetAllReturnRequestReasonsAsync()).ToPagedList(searchModel);

            //prepare list model
            var model = new ReturnRequestReasonListModel().PrepareToGrid(searchModel, reasons, () =>
            {
                return(reasons.Select(reason => reason.ToModel <ReturnRequestReasonModel>()));
            });

            return(model);
        }
Esempio n. 2
0
        /// <summary>
        /// Prepare paged return request reason list model
        /// </summary>
        /// <param name="searchModel">Return request reason search model</param>
        /// <returns>Return request reason list model</returns>
        public virtual ReturnRequestReasonListModel PrepareReturnRequestReasonListModel(ReturnRequestReasonSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get return request reasons
            var reasons = _returnRequestService.GetAllReturnRequestReasons();

            //prepare list model
            var model = new ReturnRequestReasonListModel
            {
                //fill in model values from the entity
                Data  = reasons.PaginationByRequestModel(searchModel).Select(reason => reason.ToModel()),
                Total = reasons.Count
            };

            return(model);
        }