示例#1
0
        public IHttpActionResult GetFavorite(VocabularyVM model)
        {
            // 取得用戶資料
            string guestID = UserInformationHelper.GetUserGuestID();

            string searchWord        = model.SearchWord;
            int    currentPageNumber = model.CurrentPageNumber;
            int    pageSize          = model.PageSize;
            string sortExpression    = model.SortExpression;
            string sortDirection     = model.SortDirection;
            int    totalRows         = 0;

            BaseInfo baseReturn;
            List <VocabularyInfo> vocabularyList = _vocabularyService.GetUserFavoriteWords(guestID, searchWord, currentPageNumber,
                                                                                           pageSize, sortExpression, sortDirection, out totalRows, out baseReturn);

            model.returnMsgNo    = baseReturn.returnMsgNo;
            model.returnMsg      = baseReturn.returnMsg;
            model.TotalRows      = totalRows;
            model.TotalPages     = Utilities.CalculateTotalPages(totalRows, pageSize);
            model.VocabularyList = vocabularyList;

            if (baseReturn.returnMsgNo != 1)
            {
                return(BadRequest(baseReturn.returnMsg));
            }

            return(Ok(model));
        }