示例#1
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));
        }