Ejemplo n.º 1
0
        public ActionResult PrzypiszPrzedmioty(int id)
        {
            ViewBag.Current = "Grupy";    // Aktualne zaznaczenie zakladki Profil w Menu

            var grupa = _repo.GetGroupByID(id);

            if (grupa != null)
            {
                var przedmiotyPrzypisane = grupa.Przedmioty.ToList();
                var wszystkiePrzedmioty  = _repo2.GetAllPrzedmioty.ToList();
                var mozliweDoWyboru      = wszystkiePrzedmioty.Except(przedmiotyPrzypisane).ToList();

                PrzedmiotyGrupyViewModel model = new PrzedmiotyGrupyViewModel {
                    AvailablePrzedmioty = mozliweDoWyboru, RequestedPrzedmioty = przedmiotyPrzypisane
                };
                model.SavedRequested = string.Join(",", model.RequestedPrzedmioty.Select(p => p.id_przedmiotu.ToString()).ToArray());
                return(View(model));
            }
            else
            {
                TempData["message"] = "Taka grupa nie istnieje!";
                TempData["status"]  = "invalid";
                return(View());
            }
        }
Ejemplo n.º 2
0
        public ViewResult ListaStudentow(int id, string sortOrder, string nazwa)
        {
            _logger.Info("GrupyController.ListaStudentow => HTTP POST");
            ViewBag.Current     = "Grupy";   // Aktualne zaznaczenie zakladki Profil w Menu
            ViewBag.CurrentSort = sortOrder; // Zachowanie sortowania pomiędzy przejściami stron

            ViewBag.NazwaGrupy = _repo.GetGroupByID(id).nazwa_grupy;

            ViewBag.IDStudentaSortParm = sortOrder == "ID Studenta asc" ? "ID Studenta desc" : "ID Studenta asc";
            ViewBag.NameSortParm       = sortOrder == "Name asc" ? "Name desc" : "Name asc";
            ViewBag.LastNameSortParm   = sortOrder == "LastName asc" ? "LastName desc" : "LastName asc";
            ViewBag.IndexSortParm      = sortOrder == "Index asc" ? "Index desc" : "Index asc";

            var students = _repo1.getStudentsInGroup(id);

            switch (sortOrder)
            {
            case "ID Studenta desc":
                students = students.OrderByDescending(s => s.imie);
                break;

            case "ID Studenta asc":
                students = students.OrderBy(s => s.imie);
                break;

            case "Name desc":
                students = students.OrderByDescending(s => s.imie);
                break;

            case "Name asc":
                students = students.OrderBy(s => s.imie);
                break;

            case "LastName desc":
                students = students.OrderByDescending(s => s.nazwisko);
                break;

            case "LastName asc":
                students = students.OrderBy(s => s.nazwisko);
                break;

            case "Index desc":
                students = students.OrderByDescending(s => s.nr_indeksu);
                break;

            case "Index asc":
                students = students.OrderBy(s => s.nr_indeksu);
                break;

            default:
                students = students.OrderBy(s => s.id_studenta);
                break;
            }

            var listaStudentowViewModel = new ListaStudentowViewModel
            {
                grupa           = _repo.GetGroupByID(id),
                studenci        = students,
                nazwaKontrolera = nazwa
            };

            return(View(listaStudentowViewModel));
        }