Ejemplo n.º 1
0
        public IActionResult Create(IrregularVerb verb)
        {
            if (ModelState.IsValid)
            {
                var find_verb = db.IrregularVerbs.FirstOrDefault(v => v.Infinitive == verb.Infinitive);
                var find_word = db.Words.FirstOrDefault(w => w.WordEng == verb.Infinitive);

                if (find_verb == null)
                {
                    db.IrregularVerbs.Add(verb);

                    var word = new Word()
                    {
                        WordEng = verb.Infinitive,
                        WordRu  = verb.TranslateRu
                    };
                    db.Words.Add(word);
                    db.SaveChanges();
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    find_verb.PastSimple     = verb.PastSimple;
                    find_verb.PastParticiple = verb.PastParticiple;
                    find_verb.TranslateRu    = verb.TranslateRu;
                    db.IrregularVerbs.Update(find_verb);
                    db.SaveChanges();
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(verb));
        }
Ejemplo n.º 2
0
        public IActionResult Create(Pronoun pronoun)
        {
            if (ModelState.IsValid)
            {
                if (pronoun != null)
                {
                    var find_pronoun = db.Pronouns.FirstOrDefault(w => w.PronounEng == pronoun.PronounEng);
                    var find_word    = db.Words.FirstOrDefault(w => w.WordEng == pronoun.PronounEng);

                    if (find_pronoun == null)
                    {
                        db.Pronouns.Add(pronoun);

                        var word = new Word()
                        {
                            WordEng = pronoun.PronounEng,
                            WordRu  = pronoun.PronounRu
                        };
                        db.Words.Add(word);
                        db.SaveChanges();
                    }
                    else
                    {
                        find_pronoun.PronounRu = pronoun.PronounRu;
                        db.Pronouns.Update(find_pronoun);
                        db.SaveChanges();
                    }
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(pronoun));
        }
Ejemplo n.º 3
0
        public IActionResult Create(Color color)
        {
            if (ModelState.IsValid)
            {
                if (color != null)
                {
                    var find_color = db.Colors.FirstOrDefault(w => w.ColorEng == color.ColorEng);
                    var find_word  = db.Words.FirstOrDefault(w => w.WordEng == color.ColorEng);

                    if (find_color == null)
                    {
                        db.Colors.Add(color);

                        var word = new Word()
                        {
                            WordEng = color.ColorEng,
                            WordRu  = color.ColorRu
                        };
                        db.Words.Add(word);
                        db.SaveChanges();
                    }
                    else
                    {
                        find_color.ColorRu = color.ColorRu;
                        db.Colors.Update(find_color);
                        db.SaveChanges();
                    }
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(color));
        }
Ejemplo n.º 4
0
        public IActionResult Create(Verb verb)
        {
            if (ModelState.IsValid)
            {
                if (verb != null)
                {
                    var find_verb = db.Verbs.FirstOrDefault(w => w.VerbEng == verb.VerbEng);
                    var find_word = db.Words.FirstOrDefault(w => w.WordEng == verb.VerbEng);

                    if (find_verb == null)
                    {
                        db.Verbs.Add(verb);

                        var word = new Word()
                        {
                            WordEng = verb.VerbEng,
                            WordRu  = verb.VerbRu
                        };
                        db.Words.Add(word);
                        db.SaveChanges();
                    }
                    else
                    {
                        find_verb.VerbRu = verb.VerbRu;
                        db.Verbs.Update(find_verb);
                        db.SaveChanges();
                    }
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(verb));
        }
Ejemplo n.º 5
0
        public IActionResult Create(Number number)
        {
            if (ModelState.IsValid)
            {
                if (number != null)
                {
                    var find_num  = db.Numbers.FirstOrDefault(w => w.Word == number.Word);
                    var find_word = db.Words.FirstOrDefault(w => w.WordEng == number.Word);

                    if (find_num == null)
                    {
                        db.Numbers.Add(number);

                        var word = new Word()
                        {
                            WordEng = number.Word,
                            WordRu  = number.WordRu
                        };
                        db.Words.Add(word);
                        db.SaveChanges();
                    }
                    else
                    {
                        find_num.WordRu = number.WordRu;
                        db.Numbers.Update(find_num);
                        db.SaveChanges();
                    }
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(number));
        }
Ejemplo n.º 6
0
        public IActionResult Create(WordCategory wordCategory)
        {
            if (ModelState.IsValid)
            {
                var find_verb = db.WordCategories.FirstOrDefault(w => w.Name == wordCategory.Name);

                if (find_verb == null)
                {
                    db.WordCategories.Add(wordCategory);
                    db.SaveChanges();
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(wordCategory));
        }
Ejemplo n.º 7
0
        public ActionResult <string> Post([FromBody] WordCategory wordCategory)
        {
            if (ModelState.IsValid)
            {
                var find_verb = db.WordCategories.FirstOrDefault(w => w.Name == wordCategory.Name);

                if (find_verb == null)
                {
                    db.WordCategories.Add(wordCategory);
                    db.SaveChanges();
                }
                return("OK");
            }
            return("BAD");
        }
Ejemplo n.º 8
0
        public ActionResult <string> Post([FromBody] Language language)
        {
            if (language != null)
            {
                var lang = db.Languages.FirstOrDefault(l => l.Name == language.Name);

                if (lang == null)
                {
                    db.Languages.Add(language);
                    db.SaveChanges();
                    return("OK");
                }
            }
            return("BAD");
        }
Ejemplo n.º 9
0
        public IActionResult Create(Language language)
        {
            if (language != null)
            {
                var lang = db.Languages.FirstOrDefault(l => l.Name == language.Name);

                if (lang == null)
                {
                    db.Languages.Add(language);
                    db.SaveChanges();
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(language));
        }
Ejemplo n.º 10
0
        public IActionResult Create(WordSubCategory wordSubCategory)
        {
            if (ModelState.IsValid)
            {
                var find_word = db.WordSubCategories.FirstOrDefault(w => w.Name == wordSubCategory.Name);


                if (find_word == null)
                {
                    var category = db.WordCategories.FirstOrDefault(w => w.Id == wordSubCategory.Category.Id);
                    wordSubCategory.Category = category;

                    db.WordSubCategories.Add(wordSubCategory);
                    db.SaveChanges();
                }
                return(RedirectToAction(nameof(Index), new { categoryId = wordSubCategory.Category.Id.ToString() }));
            }
            return(View(wordSubCategory));
        }
Ejemplo n.º 11
0
        public IActionResult Create(Word word)
        {
            if (ModelState.IsValid)
            {
                if (word != null)
                {
                    var find_word = db.Words.FirstOrDefault(w => w.WordEng == word.WordEng);

                    if (find_word == null)
                    {
                        db.Words.Add(word);
                        db.SaveChanges();
                    }
                    else
                    {
                        find_word.WordRu = word.WordRu;
                        db.Words.Update(find_word);
                        db.SaveChanges();
                    }
                    return(RedirectToAction(nameof(Index), new { filter = Request.Cookies["filter"] }));
                }
            }
            return(View(word));
        }
Ejemplo n.º 12
0
        public ActionResult <string> Post([FromBody] Word word)
        {
            if (ModelState.IsValid)
            {
                if (word != null)
                {
                    var find_word = db.Words.FirstOrDefault(w => w.WordEng == word.WordEng);

                    if (find_word == null)
                    {
                        db.Words.Add(word);
                        db.SaveChanges();
                    }
                    else
                    {
                        find_word.WordRu = word.WordRu;
                        db.Words.Update(find_word);
                        db.SaveChanges();
                    }
                    return("OK");
                }
            }
            return("BAD");
        }