Ejemplo n.º 1
0
        //method for getting all words
        public async Task <List <Word> > Get()
        {
            using var context = new WordDataContext(_dbContextOptions);
            var words = await context.Words.ToListAsync();

            return(words?.Count > 0 ? words : null);
        }
Ejemplo n.º 2
0
        public string Put(int id)
        {
            WordDataContext Wdc      = new WordDataContext();
            WordList        wordList = new WordList()
            {
                Id       = 1,
                Language = "French",
                Words    = new List <Word>()
            };

            Word testWord = new Word();

            testWord.Id              = 5;
            testWord.NativeLanguage  = "mister";
            testWord.TypeOfSpeech    = TypeOfSpeech.Noun;
            testWord.ForeignLanguage = "monsieur";
            wordList.Words.Add(testWord);
            Wdc.WordLists.Add(wordList);
            Wdc.SaveChanges();
            string jsonData = JsonConvert.SerializeObject(wordList);

            return(jsonData.ToString());
        }
Ejemplo n.º 3
0
 public WordsController(WordDataContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 //methond for updating existing word entity
 public void Update(Word entity)
 {
     using var context = new WordDataContext(_dbContextOptions);
     context.Words.Update(entity);
     context.SaveChanges();
 }
Ejemplo n.º 5
0
 //method for retrieving single record based on word value
 public async Task <Word> Get(string word)
 {
     using var context = new WordDataContext(_dbContextOptions);
     return(await context.Words.SingleOrDefaultAsync(w => w.Value == word));
 }
 public DuolingoUsersController(WordDataContext context)
 {
     _context   = context;
     dupContext = _context;
 }