Example #1
0
        public async Task <ActionResult <ModelWord> > Endings(ModelWord modelWord)
        {
            string word = string.Empty;

            try
            {
                word = modelWord.ResWord;//ResultWord
            }
            catch (Exception ex) {
                return(CreatedAtAction("GetEndings", defaultDictionary));
            }
            if (string.IsNullOrEmpty(word))
            {
                return(CreatedAtAction("GetEndings", defaultDictionary));
            }

            word = word.ToLower();
            // In case  user sent word(not null) we can start analyzing
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            foreach (KeyValuePair <string, string> kvp in endings.GetResult(word))
            {
                dictionary.Add(kvp.Key, kvp.Value);
            }
            return(CreatedAtAction("GetEndings", dictionary));
        }
Example #2
0
        public void DeleteColod(int _id)
        {
            db     = new ColodContext();
            wordDb = new WordContext();

            db.Colods.Load(); // загрузка данных
            wordDb.Words.Load();

            ColodContext ColodContext = new ColodContext();
            WordContext  wordContext  = new WordContext();

            ModelColod card = ColodContext.Colods
                              .Where(x => x.Id == _id)
                              .FirstOrDefault();

            ColodContext.Colods.Remove(card);
            ColodContext.SaveChanges();

            ModelWord modelWord = wordContext.Words //удаление всех слов с таким же id колоды
                                  .Where(x => x.Colods == _id)
                                  .FirstOrDefault();

            if (modelWord != null)
            {
                wordContext.Words.Remove(modelWord);
                wordContext.SaveChanges();
            }
        }
Example #3
0
        public void DeleteCard(int _id)
        {
            db = new WordContext();
            db.Words.Load(); // загрузка данных
            WordContext WordContext = new WordContext();

            ModelWord card = WordContext.Words
                             .Where(x => x.Id == _id)
                             .FirstOrDefault();

            WordContext.Words.Remove(card);
            WordContext.SaveChanges();
        }
Example #4
0
        public void AddCard(string _word, string _translate, int _progress, int _colods, bool _isChecked)
        {
            db = new WordContext();

            db.Words.Load(); // загрузка данных

            ModelWord AddCard = new ModelWord();

            AddCard.Word      = _word;
            AddCard.Translate = _translate;
            AddCard.IsChecked = _isChecked;
            AddCard.Progress  = _progress;
            AddCard.Colods    = _colods;
            db.Words.Add(AddCard);
            db.SaveChanges();
        }
Example #5
0
        public async Task <ActionResult <ModelWord> > Endings(ModelWord modelWord)
        {
            string word = modelWord.word;

            word = word.ToLower();
            Dictionary <string, string> dicts = new Dictionary <string, string>();

            if (string.IsNullOrEmpty(word))
            {
                return(null);
            }

            await Task.Run(() =>
            {
                foreach (KeyValuePair <string, string> kvp in endings.GetResult(word))
                {
                    dicts.Add(kvp.Key, kvp.Value);
                }
            });

            //return json;
            return(CreatedAtAction("GetEndings", dicts));
        }