Esempio n. 1
0
        public IActionResult ShowGroup(int GroupID = 1, string returnUrl = "/")
        {
            var model = new ShowGroupViewModel {
                Users    = context.Students.Where(x => x.GroupID == GroupID).ToList <IUser>() ?? new List <IUser>(),
                Lectures = repository.Lectures.Where(x => x.GroupID == GroupID).ToList() ?? new List <Lecture>(), returnUrl = returnUrl
                , Group  = repository.GetGroupById(GroupID)
            };

            return(View(model));
        }
Esempio n. 2
0
        public async Task <IActionResult> List()
        {
            var user = await Manager.FindByNameAsync(this.User.Identity.Name) as StudentUser;

            var group    = Groups.GetGroupById(user.GroupID);
            var lectures = Groups.Lectures.Where(x => x.GroupID == group.GroupID).OrderByDescending(x => x.Date).ToList();
            var model    = new GroupInfoViewModel {
                Lectures = lectures,
                Group    = group,
                Students = Context.Students.Where(x => x.GroupID == group.GroupID).ToList <IUser>()
            };

            return(View(model));
        }
        public async Task <IActionResult> StudentProfile(string returnUrl)
        {
            var sanitizer = new HtmlSanitizer();
            var user      = await Manager.FindByNameAsync(this.User.Identity.Name);

            var model = new StudentProgressViewModel();

            model.User              = user;
            model.returnUrl         = returnUrl;
            model.Tasks             = Docs.GetStudentTasks(user.Id) ?? new List <StTask>();
            model.Group             = Groups.GetGroupById(((StudentUser)user).GroupID);
            model.UnvisitedLectures = Groups.Lectures.Where(x => x.Date < DateTime.Now && !x.Visits.Any(y => y.VisitorID == user.Id) && x.GroupID == model.Group.GroupID).AsNoTracking().ToList() ?? new List <Lecture>();
            model.VisitedLectures   = Groups.Lectures.Where(x => x.Date < DateTime.Now && x.Visits.Any(y => y.VisitorID == user.Id) && x.GroupID == model.Group.GroupID).AsNoTracking().ToList() ?? new List <Lecture>();
            model.HtmlData          = sanitizer.Sanitize(CommonMark.CommonMarkConverter.Convert(user.Description ?? "### No description"));


            return(View(model));
        }
Esempio n. 4
0
        public string GetPopularGroup(string id)
        {
            Group  popularGroup = _groupsRepository.GetGroupById(id);
            string popular;

            if (popularGroup.members_count < 100000)
            {
                popular = "не популярна";
            }
            else if (popularGroup.members_count < 1000000)
            {
                popular = "популярна";
            }
            else
            {
                popular = "сверх популярна";
            }
            return(popular);
        }
Esempio n. 5
0
 public async Task <Group> GetGroupById(int id)
 {
     return(await _groupsRepo.GetGroupById(id));
 }