Example #1
0
        // GET: Parents
        public async Task <IActionResult> Index(SortState sortState, int page = 1)
        {
            ParentsFilterViewModel filter = HttpContext.Session.Get <ParentsFilterViewModel>(filterKey);

            if (filter == null)
            {
                filter = new ParentsFilterViewModel
                {
                    MFullName = string.Empty,
                    FFullName = string.Empty
                };
                HttpContext.Session.Set(filterKey, filter);
            }

            string key = $"{typeof(Parent).Name}-{page}-{sortState}-{filter.MFullName}-{filter.FFullName}";

            if (!_cache.TryGetValue(key, out ParentsViewModel model))
            {
                model = new ParentsViewModel();

                IQueryable <Parent> parents = GetSortedParents(sortState, filter.MFullName, filter.FFullName);

                int count = parents.Count();

                model.PageViewModel = new PageViewModel(page, count, pageSize);

                model.Parents                = count == 0 ? new List <Parent>() : parents.Skip((model.PageViewModel.PageIndex - 1) * pageSize).Take(pageSize).ToList();
                model.SortViewModel          = new SortViewModel(sortState);
                model.ParentsFilterViewModel = filter;

                _cache.Set(key, model);
            }

            return(View(model));
        }
Example #2
0
        public ActionResult ParentsLanding()
        {
            Parent           parent    = Session["ParentObject"] as Parent;
            ParentsViewModel viewModel = new ParentsViewModel();

            viewModel.Students = dbContext.Students.Where(s => s.ParentID == parent.ParentID).ToList();
            List <Guid>       studentIDs  = viewModel.Students.Select(d => d.StudentID).ToList();
            List <QuizResult> quizResults = dbContext.QuizResults.Where(d => studentIDs.Contains(d.StudentID)).ToList();

            viewModel.Reports = new List <Reports>();
            List <Guid> subjectIDs     = new List <Guid>();
            var         groupedReports = quizResults.GroupBy(d => d.Quizze.SubjectID);

            foreach (var item in groupedReports)
            {
                subjectIDs.Add(item.Key);
            }
            foreach (var item in subjectIDs)
            {
                viewModel.Reports.Add(new Reports()
                {
                    Subject     = dbContext.Subjects.Where(d => d.SubjectID == item).FirstOrDefault().SubjectName,
                    ReportCount = quizResults.Where(d => d.Quizze.SubjectID == item).ToList().Count()
                });
            }
            return(View(viewModel));
        }
 public AddParentSubViewModel(ParentsViewModel parentsViewModel)
 {
     _parentsViewModel = parentsViewModel;              // Do zadeklarowanej wcześniej zmiennej przypisujemy uchwyt do Form1
 }
Example #4
0
 public UpdateParentCommand(ParentsViewModel VM)
 {
     vm = VM;
 }
Example #5
0
 public AddParentCommand(ParentsViewModel VM)
 {
     vm = VM;
 }
 public ParentsView()
 {
     InitializeComponent();
     DataContext = new ParentsViewModel();
 }
Example #7
0
 public DeleteParentCommand(ParentsViewModel VM)
 {
     vm = VM;
 }