public IActionResult SaveVerb([FromBody] VerbViewModel model)
        {
            var verbForms = new List <PersonVerbToVerbDto>();

            foreach (var(tense, verbForm) in model.VerbForms)
            {
                foreach (var(person, verbForm2) in verbForm)
                {
                    foreach (var(number, verbForm3) in verbForm2)
                    {
                        verbForms.Add(new PersonVerbToVerbDto
                        {
                            TenseVerbId  = verbForm3.TenseVerbId,
                            PersonVerbId = verbForm3.PersonVerbId,
                            NumberVerbId = verbForm3.NumberVerbId,
                            Id           = verbForm3.Id,
                            VerbId       = verbForm3.VerbId,
                            VerbEn       = verbForm3.VerbEn,
                            VerbRu       = verbForm3.VerbRu,
                        });
                    }
                }
            }
            var result = _verbsService.SaveVerb(new VerbDto
            {
                Id                = model.Id,
                InfinitiveRu      = model.InfinitiveRu,
                InfinitiveEn      = model.InfinitiveEn,
                IsIrregular       = model.IsIrregular,
                PersonVerbToVerbs = verbForms.ToArray(),
            });

            if (!result.Success)
            {
                return(Json(result));
            }

            return(Json(result));
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            var           currVerb    = RandomVerbSelector.GetRandomVerb();
            var           currOptions = RandomVerbSelector.GetRandomConjugationOption();
            var           conjugation = currVerb.Conjugate(currOptions);
            VerbViewModel model       = new VerbViewModel();

            model.mood  = currOptions.Mood.ToString();
            model.tense = currOptions.Tense.ToString();
            //model.pronoun = currOptions.Pronoun.ToString();
            var pronounDictionary = new Dictionary <Pronoun, string>();

            pronounDictionary.Add(Pronoun.FirstPersonSingular, "je");
            pronounDictionary.Add(Pronoun.SecondPersonSingular, "tu");
            pronounDictionary.Add(Pronoun.ThirdPersonSingular, "il/elle");
            pronounDictionary.Add(Pronoun.FirstPersonPlural, "nous");
            pronounDictionary.Add(Pronoun.SecondPersonPlural, "vous");
            pronounDictionary.Add(Pronoun.ThirdPersonPlural, "ils/elles");
            model.pronoun     = pronounDictionary[currOptions.Pronoun];
            model.verb        = currVerb.Infinitive;
            model.conjugation = conjugation;
            return(View(model));
        }