Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Plecak Plec    = new Plecak();
            int    Seed    = 1;
            int    MaxWaga = 10;

            Seed    = int.Parse(textBox1.Text);
            MaxWaga = int.Parse(textBox2.Text);

            RandomNumberGenerator x = new RandomNumberGenerator(Seed);

            Przedmiot Pom = new Przedmiot();

            Plec.UstawMaxWage(MaxWaga);

            for (int i = 0; i < 10; i++)
            {
                Pom.UstawWageIWartosc(x.nextInt(1, 30), x.nextInt(1, 30));

                if (Plec.CzyWejdzie(Pom))
                {
                    Plec.DodajPrzedmiot(Pom);
                    listBox1.Items.Add(" Przedmiot o wadze " + Pom.ZwrocWage() + " i wartosci " + Pom.ZwrocWartosc() + " zmiescil sie \n");
                }
                else
                {
                    listBox1.Items.Add(" Przedmiot o wadze " + Pom.ZwrocWage() + " i wartosci " + Pom.ZwrocWartosc() + " nie zmiescil sie \n");
                }
            }
            listBox1.Items.Add("Suma wagi przedmiotow: " + Plec.PokazWage() + "\n");
            listBox1.Items.Add("Suma wartosci przedmiotow: " + Plec.PokazWartosc() + "\n");
        }
Пример #2
0
        private void RegisterSemester(object parameter)
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            Guid idSemestr   = Semestr.FindSemestrIdByName(_selectedSemester);
            Guid idPrzedmiot = Przedmiot.FindPrzedmiotIdByFullName(_selectedPrzedmiot);

            if (!Semestr.CheckSemestrExistInGroup(CurrentGroupId, idSemestr))
            {
                var grupaSemestrPrzedmiot = new GrupaSemestrPrzedmiot
                {
                    Id_Grupa     = CurrentGroupId,
                    Id_Przedmiot = idPrzedmiot,
                    Id_Semestr   = idSemestr
                };

                context.GrupaSemestrPrzedmiots.InsertOnSubmit(grupaSemestrPrzedmiot);
                context.SubmitChanges();
            }
            else
            {
                MessageBox.Show("Semestr jest już wpisany", "Uwaga", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            Window frm = (Window)parameter;

            frm.Close();
        }
Пример #3
0
        public void EdytujOcene_EmptyString_NotUpdated()
        {
            var przedmiot = new Przedmiot("Historia");

            przedmiot.EdytujOcene(" ");
            Assert.AreEqual("Historia", przedmiot.nazwa);
        }
Пример #4
0
        public IActionResult UpdateStudentNote([FromRoute] int studentIndex, [FromRoute] int lectureIndex, [FromRoute] int noteIndex, [FromBody] Ocena note)
        {
            Student student = _educationSystemData.GetStudents()
                              .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex);

            Przedmiot lecture = _educationSystemData.GetLectures()
                                .FirstOrDefault(lectureObj => lectureObj.Id == lectureIndex);

            Ocena noteTemp = _educationSystemData.GetNotes()
                             .FirstOrDefault(noteObj => noteObj.Id == noteIndex);

            if (student == null || lecture == null || note == null)
            {
                return(NotFound());
            }

            if (note.Wartosc < 2.0 || note.Wartosc > 5.0)
            {
                return(BadRequest());
            }

            noteTemp.Wartosc = note.Wartosc;

            _educationSystemData.UpdateStudentNote(student, lecture, noteTemp);

            return(Ok(/*student*/));
        }
        public void EdytujNazwe_EmptyString_NotUpdated()
        {
            var przedmiot = new Przedmiot("Chemia");

            przedmiot.EdytujNazwe("");
            Assert.AreEqual("Chemia", przedmiot.name);
        }
Пример #6
0
    private static List <Przedmiot> ZwrocListePrzedmiotow(string komenda)
    {
        try{
            List <Przedmiot> listaPrzedmiotow = new List <Przedmiot>();
            string           sqlQuery         = komenda;
            Debug.Log(komenda);

            using (IDbConnection connection = new SqliteConnection(path) as IDbConnection) {
                connection.Open();

                using (IDbCommand command = connection.CreateCommand()) {
                    command.CommandText = sqlQuery;
                    using (IDataReader reader = command.ExecuteReader()){
                        while (reader.Read())
                        {
                            Przedmiot przedmiot = new Przedmiot {
                                ID             = reader.GetInt32(0),
                                Nazwa          = reader.GetString(1),
                                Cena           = reader.GetFloat(2),
                                CalkowitaIlosc = reader.GetInt32(3),
                                Opis           = reader.GetString(4)
                            };
                            listaPrzedmiotow.Add(przedmiot);
                        }
                    }
                }
            }
            return(listaPrzedmiotow);
        }catch (Exception e) {
            Debug.Log("Blad przy zwracaniu listy przedmiotow");
            Debug.Log(e);
        }
        return(null);
    }
Пример #7
0
        public IActionResult PostSaveLecturesStudent([FromRoute] int studentIndex, [FromBody] Przedmiot lecture)
        {
            Student studentExisted = _educationSystemData.GetStudents()
                                     .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex);

            Przedmiot lectureExisted = _educationSystemData.GetLectures()
                                       .FirstOrDefault(lectureObj => lectureObj.Id == lecture.Id);

            if (studentExisted == null || lectureExisted == null)
            {
                return(BadRequest());
            }

            foreach (var przedmiot in studentExisted.Przedmioty)
            {
                if (przedmiot.Id == lectureExisted.Id)
                {
                    return(BadRequest());
                }
            }

            _educationSystemData.AddStudentToLecture(studentExisted, lectureExisted);

            return(CreatedAtAction("students", new { idStudent = studentExisted.Indeks }, lectureExisted));
        }
Пример #8
0
        public ActionResult PlikiPrzedmiotu([Bind(Include = "ID")] Przedmiot przedmiot, HttpPostedFileBase[] fileUpload)
        {
            if (Session["Status"] != "Nauczyciel")
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (przedmiot.ID != null)
            {
                string    sciezka  = null;
                Przedmiot original = db.Przedmioty
                                     .Include(p => p.Pliki)
                                     .Include(p => p.Tresc_ksztalcenia)
                                     .SingleOrDefault(p => p.ID == przedmiot.ID);

                if (fileUpload != null)
                {
                    foreach (var file in fileUpload)
                    {
                        sciezka = FileHandler.saveFile(file);
                        var newFile = new Plik {
                            PrzedmiotID = przedmiot.ID, FilePath = sciezka, NauczycielID = Convert.ToInt32(Session["UserID"]), DataDodania = DateTime.Now
                        };
                        db.Pliki.Add(newFile);
                        original.Pliki.Add(newFile);
                    }
                    db.SaveChanges();
                }

                return(RedirectToAction("Przedmioty"));
            }
            ViewBag.Tresc_ksztalcenia = new SelectList(db.Tresci_ksztalcenia, "PrzedmiotID", "PrzedmiotID", przedmiot.ID);
            return(View(przedmiot));
        }
Пример #9
0
        public IActionResult GetNotesFromLecture([FromRoute] int lectureIndex)
        {
            Przedmiot lecture = _educationSystemData.GetLectures()
                                .FirstOrDefault(lectureObj => lectureObj.Id == lectureIndex);

            List <Ocena> oceny = new List <Ocena>();

            if (lecture == null)
            {
                return(NotFound());
            }

            foreach (var ocenaTemp in _educationSystemData.GetNotes())
            {
                if (ocenaTemp.IdPrzedmiot == lectureIndex)
                {
                    oceny.Add(ocenaTemp);
                }
            }

            if (oceny == null || oceny.Count() <= 0)
            {
                return(NotFound());
            }

            return(Ok(oceny));
        }
Пример #10
0
        public ActionResult Edit([Bind(Include = "ID,nazwa,level")] Przedmiot przedmiot, HttpPostedFileBase fileUpload)
        {
            if ((string)Session["Status"] != "Admin")
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid)
            {
                Tresc_ksztalcenia oldTk   = null;
                string            sciezka = null;
                if (fileUpload != null)
                {
                    oldTk   = db.Tresci_ksztalcenia.Find(przedmiot.ID);
                    sciezka = FileHandler.SaveFile(fileUpload);
                    var tk = new Tresc_ksztalcenia(przedmiot.ID, sciezka);
                    przedmiot.Tresc_ksztalcenia = tk;
                    db.Tresci_ksztalcenia.Remove(oldTk);
                    db.Tresci_ksztalcenia.Add(tk);
                }

                db.Entry(przedmiot).State = EntityState.Modified;
                db.SaveChanges();

                if (oldTk != null)
                {
                    FileHandler.DeleteFile(oldTk.plikSciezka);
                }

                return(RedirectToAction("Index"));
            }
            ViewBag.Tresc_ksztalcenia = new SelectList(db.Tresci_ksztalcenia, "PrzedmiotID", "PrzedmiotID", przedmiot.ID);
            return(View(przedmiot));
        }
Пример #11
0
        public ActionResult Details(int?id)
        {
            if ((string)Session["Status"] != "Admin")
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Przedmiot przedmiot = db.Przedmioty
                                  .Include(p => p.Lekcje)
                                  .Include("Lekcje.Nauczyciel")
                                  .Include("Lekcje.Klasa")
                                  .Include(p => p.Oceny)
                                  .Include("Oceny.Nauczyciel")
                                  .Include("Oceny.Uczen")
                                  .Include(p => p.Pliki)
                                  .Include(p => p.Testy)
                                  .Include("Testy.Nauczyciel")
                                  .Include("Testy.Klasa")
                                  .Include(p => p.Tresc_ksztalcenia)
                                  .Where(p => p.ID == id).FirstOrDefault();

            if (przedmiot == null)
            {
                return(HttpNotFound());
            }
            przedmiot.Tresc_ksztalcenia.plikSciezka = FileHandler.GetFileName(przedmiot.Tresc_ksztalcenia.plikSciezka);
            return(View(przedmiot));
        }
Пример #12
0
        public ActionResult Delete(int id)
        {
            Przedmiot prz = repoPrzedmioty.Get(id);

            repoPrzedmioty.Delete(prz);
            return(RedirectToAction("Index"));
        }
Пример #13
0
        public void EdytujNazwe_EmptyString_NotUpdated()
        {
            var przedmiot = new Przedmiot("Programowanie");

            przedmiot.Edytuj("");
            Assert.AreEqual("Programowanie", przedmiot.name);
        }
Пример #14
0
        public void EdytujNazwe_ValidString_Updated()
        {
            var przedmiot = new Przedmiot("Programowanie");

            przedmiot.Edytuj("Bazy danych");
            Assert.AreEqual("Bazy danych", przedmiot.name);
        }
        public async Task <IActionResult> Edit(string id, [Bind("PrzedmiotID,Nazwa,DlaKlasy,LiczbaGodzinTygodniowo")] Przedmiot przedmiot)
        {
            if (id != przedmiot.PrzedmiotID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(przedmiot);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrzedmiotExists(przedmiot.PrzedmiotID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(przedmiot));
        }
Пример #16
0
        public IActionResult DeleteNotesFromLecture([FromRoute] int lectureIndex, [FromRoute] int idNote)
        {
            Przedmiot lecture = _educationSystemData.GetLectures()
                                .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == lectureIndex);

            Ocena note = _educationSystemData.GetNotes()
                         .FirstOrDefault(noteObj => noteObj.IdOceny == idNote &&
                                         noteObj.IdPrzedmiot == lecture.Id);

            if (lecture == null || note == null)
            {
                return(NotFound());
            }

            Student student = _educationSystemData.GetStudents()
                              .FirstOrDefault(studentObj => studentObj.Oceny.Any(ocenyObj => ocenyObj == note.Id));

            if (student == null)
            {
                return(NotFound());
            }

            _educationSystemData.DeleteNote(student, lecture, note);

            return(Ok());
        }
Пример #17
0
    public static String DodajNowyPrzedmiot(Przedmiot przedmiot)
    {
        try
        {
            string sqlQuery = "INSERT INTO Przedmioty(Nazwa, Cena, Ilosc, Opis) VALUES('" + przedmiot.Nazwa + "', '" + przedmiot.Cena + "', '" + przedmiot.CalkowitaIlosc +
                              "', '" + przedmiot.Opis + "');";

            using (IDbConnection connection = new SqliteConnection(path) as IDbConnection)
            {
                connection.Open();

                using (IDbCommand command = connection.CreateCommand())
                {
                    command.CommandText = sqlQuery;
                    using (IDataReader reader = command.ExecuteReader())
                    {
                    }
                }
            }
            return("Pomyslnie dodano przedmiot");
        }
        catch (Exception e)
        {
            Debug.Log("Blad przy dodawaniu nowego przedmiotu");
            Debug.Log(e);
            return("Nie udalo sie dodac przedmiotu");
        }
    }
Пример #18
0
        public void PoprawnoscWart()
        {
            Przedmiot Prz = new Przedmiot();

            Prz.UstawWageIWartosc(10, 10);
            Assert.AreEqual(10, Prz.ZwrocWartosc());
        }
Пример #19
0
        public IActionResult GetSaveLecturesStudent([FromRoute] int studentIndex)
        {
            Student student = _educationSystemData.GetStudents()
                              .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex);

            List <Przedmiot> listLectures = new List <Przedmiot>();

            if (student == null || student.Przedmioty == null)
            {
                return(NotFound());
            }

            if (student.Przedmioty.Count() <= 0)
            {
                return(NotFound());
            }

            foreach (var lectureObj in student.Przedmioty)
            {
                Przedmiot przedmiotRef = _educationSystemData.getLecture(lectureObj.Id);

                listLectures.Add(przedmiotRef);
            }

            return(Ok(listLectures));
        }
Пример #20
0
        public IActionResult PostSaveLecturesStudent([FromRoute] int studentIndex, [FromRoute] int Indexlecture)
        {
            Student studentExisted = _educationSystemData.GetStudents()
                                     .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex);

            Przedmiot existedLecture = existedLecture = _educationSystemData.GetLectures()
                                                        .FirstOrDefault(przedmiotTemp => przedmiotTemp.IdPrzedmiotu == Indexlecture);

            if (studentExisted == null ||
                existedLecture == null)
            {
                return(BadRequest());
            }

            var studentExistInLecture = existedLecture.ZapisaniStudenci.FirstOrDefault(studentObj => studentObj == studentExisted.Id);

            if (studentExistInLecture != null)
            {
                return(BadRequest());
            }

            _educationSystemData.AddStudentToLecture(studentExisted, existedLecture);

            return(CreatedAtAction("students", new { idStudent = studentExisted.Indeks }, existedLecture));
        }
Пример #21
0
        public IActionResult GetSaveConcreteNoteFromLecturesStudent([FromRoute] int studentIndex, [FromRoute] int przedmiotIndex, [FromRoute] int noteIndex)
        {
            Student student = _educationSystemData.GetStudents()
                              .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex);

            Przedmiot przedmiot = _educationSystemData.GetLectures()
                                  .FirstOrDefault(lectureObj => lectureObj.Id == przedmiotIndex);

            if (student == null || przedmiot == null)
            {
                return(NotFound());
            }

            if (student.Oceny == null || student.Oceny.Count() <= 0)
            {
                return(NotFound());
            }

            Ocena ocena = _educationSystemData.GetNotes()
                          .Find(ocenaObj => ocenaObj.Id == noteIndex &&
                                ocenaObj.IdStudent == student.Indeks &&
                                ocenaObj.IdPrzedmiot == przedmiot.Id);

            if (ocena == null)
            {
                return(NotFound());
            }

            return(Ok(ocena));
        }
Пример #22
0
        public IActionResult PostSaveLecturesStudent([FromRoute] int studentIndex, [FromRoute] int lectureIndex, [FromBody] Ocena note)
        {
            Student student = _educationSystemData.GetStudents()
                              .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex);

            Przedmiot lecture = _educationSystemData.GetLectures()
                                .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == lectureIndex);

            if (student == null || lecture == null || _educationSystemData.GetNotes() == null)
            {
                return(BadRequest());
            }

            var studentExistInLecture = lecture.ZapisaniStudenci.FirstOrDefault(studentObj => studentObj == student.Id);

            if (studentExistInLecture == null || note.Wartosc < 2.0 || note.Wartosc > 5.0)
            {
                return(BadRequest());
            }

            if (note.Wartosc != 2.0 && note.Wartosc != 2.5 &&
                note.Wartosc != 3.0 && note.Wartosc != 3.5 &&
                note.Wartosc != 4.0 && note.Wartosc != 4.5 &&
                note.Wartosc != 5.0)
            {
                return(BadRequest());
            }

            _educationSystemData.AddNoteStudentFromLecture(student, lecture, note);

            return(CreatedAtAction("students", new { idLecture = lecture.Id, idStudent = student.Indeks }, note));
        }
        public void EdytujNazwe_ValidString_Updated()
        {
            var przedmiot = new Przedmiot("Chemia");

            przedmiot.EdytujNazwe("Przyroda");
            Assert.AreEqual("Przyroda", przedmiot.name);
        }
Пример #24
0
        public IActionResult UpdateStudentNote([FromRoute] int studentIndex, [FromRoute] int lectureIndex, [FromRoute] int noteIndex, [FromBody] Ocena note)
        {
            Student student = _educationSystemData.GetStudents()
                              .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex);

            Przedmiot lecture = _educationSystemData.GetLectures()
                                .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == lectureIndex);

            if (student == null || lecture == null || note == null)
            {
                return(NotFound());
            }

            Ocena noteTemp = _educationSystemData.GetNotes()
                             .FirstOrDefault(noteObj => noteObj.IdOceny == noteIndex &&
                                             noteObj.IdPrzedmiot == lecture.Id &&
                                             noteObj.IdStudent == student.Id);

            if (noteTemp == null)
            {
                return(NotFound());
            }

            if (note.Wartosc != 2.0 && note.Wartosc != 2.5 &&
                note.Wartosc != 3.0 && note.Wartosc != 3.5 &&
                note.Wartosc != 4.0 && note.Wartosc != 4.5 &&
                note.Wartosc != 5.0)
            {
                return(BadRequest());
            }

            _educationSystemData.UpdateStudentNote(student, lecture, noteTemp, note);

            return(Ok());
        }
Пример #25
0
        public IActionResult DeleteOcena([FromRoute] int idOceny)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Ocena ocena = _educationSystemData.GetNotes()
                          .FirstOrDefault(ocenaObj => ocenaObj.IdOceny == idOceny);

            if (ocena == null)
            {
                return(NotFound());
            }

            Przedmiot lecture = _educationSystemData.GetLectures()
                                .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == ocena.IdPrzedmiotu);

            Student student = _educationSystemData.GetStudents()
                              .FirstOrDefault(studentObj => studentObj.Indeks == ocena.Indeks);

            if (lecture == null || student == null)
            {
                return(NotFound());
            }

            _educationSystemData.DeleteStudentNote(student, lecture, ocena);

            return(Ok());
        }
Пример #26
0
        public IActionResult UpdateStudentNote([FromRoute] int studentIndex, [FromRoute] int lectureIndex, [FromRoute] int noteIndex)
        {
            Student student = _educationSystemData.GetStudents()
                              .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex);

            Przedmiot lecture = _educationSystemData.GetLectures()
                                .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == lectureIndex);

            if (student == null || lecture == null)
            {
                return(NotFound());
            }

            Ocena note = _educationSystemData.GetNotes()
                         .FirstOrDefault(noteObj => noteObj.IdOceny == noteIndex &&
                                         noteObj.IdPrzedmiot == lecture.Id &&
                                         noteObj.IdStudent == student.Id);

            if (note == null)
            {
                return(NotFound());
            }

            _educationSystemData.DeleteStudentNote(student, lecture, note);

            return(Ok());
        }
Пример #27
0
        public void EdytujOcene_ValidString_Updated()
        {
            Przedmiot przedmiot = new Przedmiot("Historia");

            przedmiot.EdytujOcene("Przyroda");
            Assert.AreEqual("Przyroda", przedmiot.nazwa);
        }
Пример #28
0
        public bool SalaZajeta(Rezerwacja rezerwacja)
        {
            // Informacje danej Rezerwacji
            Przedmiot   przedmiotR   = Db.Przedmiot.FirstOrDefault(p => p.przedmiotId == rezerwacja.przedmiotId);
            Sala        sala         = Db.Sala.FirstOrDefault(s => s.salaId == rezerwacja.salaId);
            Cyklicznosc cyklicznoscR = Db.Cyklicznosc.FirstOrDefault(c => c.cyklicznoscId == rezerwacja.cyklicznoscId);

            // Przedmioty prowadzone przez wykladowce
            List <Sala> listaSal = uni.ReadAllT(new Sala()).Where(s => s.salaId == sala.salaId).ToList();
            // Wszystkie cykle w dniu nowej rezerwacji
            List <Cyklicznosc> listaCyklicznosci = uni.ReadAllT(new Cyklicznosc()).Where(c => c.od_ktorego_dnia == cyklicznoscR.od_ktorego_dnia).ToList();
            // Lista rezerwacji dla wykladowcy
            List <Rezerwacja> listaRezerwacji = uni.ReadAllT(new Rezerwacja()).Where(
                r => listaCyklicznosci.Any(c => c.cyklicznoscId == r.cyklicznoscId) &&
                listaSal.Any(s => s.salaId == r.salaId)
                ).ToList();

            foreach (var rezer in listaRezerwacji)
            {
                // Info pojedynczej rezerwacji z listy
                Przedmiot   przed = uni.ReadAllT(new Przedmiot()).FirstOrDefault(p => p.przedmiotId == rezer.przedmiotId);
                Cyklicznosc cykl  = uni.ReadAllT(new Cyklicznosc()).FirstOrDefault(c => c.cyklicznoscId == rezer.cyklicznoscId);

                var poczR  = Convert.ToDateTime(cykl.od_ktorej_godziny);
                var konR   = Convert.ToDateTime(cykl.od_ktorej_godziny).AddMinutes(przed.czas_trwania);
                var poczNR = Convert.ToDateTime(cyklicznoscR.od_ktorej_godziny);
                var konNR  = Convert.ToDateTime(cyklicznoscR.od_ktorej_godziny).AddMinutes(przedmiotR.czas_trwania);

                if (poczNR.Ticks >= poczR.Ticks && poczNR.Ticks <= konR.Ticks - 1 || konNR.Ticks >= poczR.Ticks && konNR.Ticks <= konR.Ticks - 1)
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #29
0
        public void PrzypiszUnikatowyPrzemdiotDoNauczyciela()
        {
            //Arrange (przygotuj test)
            Przedmiot.ListaPrzedmiotow = new List <int>();
            PrzedmiotRepository przedmiotRepository = new PrzedmiotRepository();
            var przedmiot1 = przedmiotRepository.Pobierz(1);

            Przedmiot.ListaPrzedmiotow.Add(przedmiot1.PrzedmiotId);
            var przedmiot2 = przedmiotRepository.Pobierz(2);

            Przedmiot.ListaPrzedmiotow.Add(przedmiot2.PrzedmiotId);

            NauczycielRepository nauczycielRepository = new NauczycielRepository();
            Nauczyciel           nauczyciel           = nauczycielRepository.Pobierz(1);

            nauczyciel.PrzedmiotId = Przedmiot.WybranyPrzedmiotZListy(0);
            var oczekiwana1 = nauczyciel;

            nauczycielRepository   = new NauczycielRepository();
            nauczyciel             = nauczycielRepository.Pobierz(2);
            nauczyciel.PrzedmiotId = Przedmiot.WybranyPrzedmiotZListy(0);
            var oczekiwana2 = nauczyciel;

            //Act (dzialaj)
            var aktualna1 = przedmiot1;
            var aktualna2 = przedmiot2;

            //Assert (potwierdz test)
            Assert.AreEqual(oczekiwana1.PrzedmiotId, aktualna1.PrzedmiotId);
            Assert.AreEqual(oczekiwana2.PrzedmiotId, aktualna2.PrzedmiotId);
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Nazwa,KategoriaID,TypID,RodzajID,Ilosc,Price,SerialNumber,CreationDate,Description")] Przedmiot przedmiot)
        {
            if (id != przedmiot.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(przedmiot);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrzedmiotExists(przedmiot.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["KategoriaID"] = new SelectList(_context.Kategorie, "ID", "Name", przedmiot.KategoriaID);
            ViewData["RodzajID"]    = new SelectList(_context.Rodzaje, "ID", "Name", przedmiot.RodzajID);
            ViewData["TypID"]       = new SelectList(_context.Typy, "ID", "Name", przedmiot.TypID);
            return(View(przedmiot));
        }