コード例 #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));
        }
コード例 #2
0
        public IActionResult Index()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Intro"));
            }
            HomeViewModel model = new HomeViewModel();

            model.user              = _userManager.GetBy(User.Identity.Name, User.Identity.Name).MappingDto();
            model.user.CourseCount  = _courseServices.CourseCount(User.Identity.Name);
            model.user.FolderCount  = _folderServices.FolderCount(User.Identity.Name);
            model.user.ClassCount   = _classServices.ClassCount(User.Identity.Name);
            ViewData["Page.Title"]  = model.user.ID;
            ViewData["Page.Target"] = "Trang chủ";
            return(View(model));
        }