Exemplo n.º 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"));
        }
Exemplo n.º 2
0
        public IActionResult Sets(string id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Intro"));
            }
            if (id == null || (!_userManager.IsActive(id) && !_userManager.IsAdmin(User.Identity.Name)))
            {
                id = User.Identity.Name;
            }
            UserViewModel model = new UserViewModel();

            model.user              = _userManager.GetBy(User.Identity.Name, User.Identity.Name);
            model.owner             = _userManager.GetBy(id);
            model.owner.CourseCount = _courseServices.CourseCount(id);
            model.owner.FolderCount = _folderServices.FolderCount(id);
            model.owner.ClassCount  = _classServices.ClassCount(id);

            model.setList = new List <SetsViewModel>();
            foreach (var course in _courseServices.GetCoureList(id))
            {
                SetsViewModel temp = new SetsViewModel();
                temp.ID    = course.ID;
                temp.Name  = course.name;
                temp.count = _courseServices.GetVocabulary(course.ID).Count();

                model.setList.Add(temp);
            }

            ViewData["Page.Title"]  = model.user.ID;
            ViewData["Page.Target"] = "Học phần";
            return(View(model));
        }
Exemplo n.º 3
0
        public IActionResult AddSet()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Intro"));
            }
            SetsViewModel model = new SetsViewModel();

            model.user = _userManager.GetBy(User.Identity.Name, User.Identity.Name);

            ViewData["Page.Title"]  = model.user.ID;
            ViewData["Page.Target"] = "Tạo học phần";
            return(View(model));
        }