Beispiel #1
0
        public IActionResult AddSet(SetsViewModel model)
        {
            var courseToCreate = new CourseDto()
            {
                IDuser   = _userManager.GetBy(User.Identity.Name, User.Identity.Name).ID,
                name     = model.Name,
                describe = model.Describe,
                link     = ""
            };

            _courseServices.CreateCourse(courseToCreate);

            for (int i = 0; i < model.Term.Count(); i++)
            {
                VocabularyDto vocabularyToCreate = new VocabularyDto()
                {
                    define  = model.Term.ElementAt(i),
                    explain = model.DescribeTerm.ElementAt(i),
                    image   = ""
                };
                _vocabularyServices.CreateVocabulary(vocabularyToCreate);
                _vocabularyServices.CreateListVocabulary(_courseServices.GetNewestID(), _vocabularyServices.GetNewestID());
            }
            return(RedirectToAction("Index", "Home"));
        }