示例#1
0
        public HttpResponseMessage GetWordsList(int dictionaryId, int indexOfPhraseList, int totalPages)
        {
            var    aPhraseService = new PhraseService();
            string errorMessage;

            try
            {
                aPhraseService.SetSqlPhraseRepository();
                var listOfPhrase = aPhraseService.GetListOfPhrase(dictionaryId, totalPages);
                foreach (var aPhrase in listOfPhrase)
                {
                    var wordsId     = aPhrase.WordsIds;
                    var listOfWords = this.aWordService.GetListOfWordsForAPhrase(wordsId);
                    aPhrase.ListOfWords = listOfWords;
                }

                if (listOfPhrase.Any())
                {
                    return(this.ControllerContext.Request.CreateResponse(HttpStatusCode.OK, listOfPhrase));
                }

                throw new Exception("No words in dictionary");
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
            }

            return(this.ControllerContext.Request.CreateResponse(
                       HttpStatusCode.BadRequest,
                       errorMessage));
        }
示例#2
0
        public HttpResponseMessage GetAllPhrasesInDictionary(int dictionaryId, int totalPages)
        {
            var aPhraseService = new PhraseService();

            aPhraseService.SetSqlPhraseRepository();
            var phraseList = aPhraseService.GetListOfPhrase(dictionaryId, totalPages);

            if (!phraseList.Any())
            {
                return(this.ControllerContext.Request.CreateResponse(
                           HttpStatusCode.BadRequest,
                           "There is no phrases in dictionary"));
            }

            return(this.ControllerContext.Request.CreateResponse(HttpStatusCode.OK, phraseList));
        }