示例#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 static void AssmStart(TestContext context)
        {
            options = new DbContextOptionsBuilder <SDSComContext>()
                      .UseInMemoryDatabase(databaseName: "SDSCom_Phrase_Tests")
                      .Options;

            db    = new SDSComContext(options);
            cache = null;

            pSvc = new PhraseService(db, cache);
        }
示例#3
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));
        }
示例#4
0
 public PhraseApi(PhraseService phraseService, TTSService tts)
 {
     PhraseService = phraseService;
 }
示例#5
0
 public Commands()
 {
     _db            = new GameBotDbContext();
     _phraseService = new PhraseService(_db);
 }
 public PhraseController(IMapper mapper)
 {
     Mapper  = mapper;
     Service = new PhraseService(mapper);
 }
示例#7
0
 public PhrasesController(PhraseService phraseService)
 {
     _phraseService = phraseService;
     smartCenter    = new SmarCenter();
 }